You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This pull request does not have a related issue as it's part of delivery
for development agreed directly with @AndreiPanko
Added an action to Variants subpage to add BC Items as additional
Variants to an existing Shopify Product.
If the parent product only had a default variant before the addition, it
is deleted from both Shopify and BC.
The variants are added under the existing the Product Option (ex. Color,
Material, or Title, if product only had the default variant)
Items cannot be added if the shop has "UOM as Variant" enabled, or if
the parent product has more than one option defined.
Fixes#26819
Fixes
[AB#468218](https://dynamicssmb2.visualstudio.com/1fcb79e7-ab07-432a-a3c6-6cf5a88ba4a5/_workitems/edit/468218)
---------
Co-authored-by: Tine Staric <[email protected]>
Co-authored-by: Jesper Schulz-Wedde <[email protected]>
Co-authored-by: Onat Buyukakkus <[email protected]>
if VariantApi.AddProductVariant(TempShopifyVariant) thenbegin
38
+
ShopifyProduct."Has Variants" := true;
39
+
ShopifyProduct.Modify(true);
40
+
end;
41
+
end;
42
+
43
+
44
+
/// <summary>
45
+
/// Checks if items can be added as variants to the product. The items cannot be added as variants if:
46
+
/// - The product has more than one option.
47
+
/// - The UoM as Variant setting is enabled.
48
+
/// </summary>
49
+
internalprocedure CheckProductAndShopSettings()
50
+
var
51
+
MultipleOptionsErr: Label'The product has more than one option. Items cannot be added as variants to a product with multiple options.';
52
+
UOMAsVariantEnabledErr: Label'Items cannot be added as variants to a product with the "%1" setting enabled for this store.', Comment = '%1 - UoM as Variant field caption';
53
+
Options: Dictionaryof [Text, Text];
54
+
begin
55
+
if Shop."UoM as Variant" then
56
+
Error(UOMAsVariantEnabledErr, Shop.FieldCaption("UoM as Variant"));
ProductPriceCalc.CalcPrice(Item, ItemVariant.Code, Item."Sales Unit of Measure", TempShopifyVariant."Unit Cost", TempShopifyVariant.Price, TempShopifyVariant."Compare at Price");
TempShopifyVariant.Barcode := CopyStr(GetBarcode(Item."No.", '', Item."Sales Unit of Measure"), 1, MaxStrLen(TempShopifyVariant.Barcode));
198
-
ProductPriceCalc.CalcPrice(Item, '', Item."Sales Unit of Measure", TempShopifyVariant."Unit Cost", TempShopifyVariant.Price, TempShopifyVariant."Compare at Price");
exit(ItemNo + Shop."SKU Field Separator" + VariantCode)
200
+
else
201
+
exit(ItemNo);
202
+
Shop."SKU Mapping"::"Vendor Item No.":
203
+
exit(VendorItemNo);
204
+
end;
205
+
end;
206
+
207
+
/// <summary>
208
+
/// Creates a temporary Shopify variant with information from an item.
209
+
/// </summary>
210
+
/// <param name="Item">The item to create the variant from.</param>
211
+
/// <param name="TempShopifyVariant">The temporary Shopify variant record set where the variant will be inserted.</param>
212
+
internalprocedure CreateTempShopifyVariantFromItem(Item: Record Item; var TempShopifyVariant: Record "Shpfy Variant" temporary)
213
+
begin
214
+
Clear(TempShopifyVariant);
215
+
TempShopifyVariant."Available For Sales" := true;
216
+
TempShopifyVariant.Barcode := CopyStr(GetBarcode(Item."No.", '', Item."Sales Unit of Measure"), 1, MaxStrLen(TempShopifyVariant.Barcode));
217
+
ProductPriceCalc.CalcPrice(Item, '', Item."Sales Unit of Measure", TempShopifyVariant."Unit Cost", TempShopifyVariant.Price, TempShopifyVariant."Compare at Price");
218
+
TempShopifyVariant.Title := ''; // Title will be assigned to "Default Title" in Shopify as no Options are set.
0 commit comments