Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
61dcf86
Added Item Attributes enum and extensions for Shpfy Product Sync
jzaksauskas Dec 17, 2025
d1915b2
Added functionality to collect and assign product options for the ite…
jzaksauskas Jan 13, 2026
afaecf4
Added functionality to check Item Attr Count and the duplicates
jzaksauskas Jan 14, 2026
bafe0ea
Added checks for missing attribute values and limits on product optio…
jzaksauskas Jan 14, 2026
66ae67e
Refactor product option checks and improve attribute validation for S…
jzaksauskas Jan 14, 2026
92e5590
Add compatibility check for item attributes before adding to Shopify
jzaksauskas Jan 14, 2026
4d2291b
Renamed procedure and added documentations for internal procedures
jzaksauskas Jan 15, 2026
7f897f5
Added functionality for product variant creation based on Item Attrib…
jzaksauskas Jan 15, 2026
fa943e5
Rename few procedures
jzaksauskas Jan 16, 2026
8b9258a
Moved Product Options Handling procedures from Create Product to Expo…
jzaksauskas Jan 16, 2026
3703f98
Add validation to prevent UoM as Variant usage if Item Attributes As …
jzaksauskas Jan 16, 2026
095ab61
Adjusted codeunit permissions
jzaksauskas Jan 16, 2026
3ad6d97
Added FillProductOptionsForShopifyVariants procedure documentation
jzaksauskas Jan 16, 2026
ffcc7f0
Refactor product option handling. Moded procedure to Product Export c…
jzaksauskas Jan 16, 2026
bdf1698
Renamed procedure
jzaksauskas Jan 16, 2026
cb45c28
Added SetShop
jzaksauskas Jan 16, 2026
d07364a
Fixed hardcoded label and moved tooltip to table ext
jzaksauskas Jan 20, 2026
2ecc413
Automated tests for Item attributes as Product Options
jzaksauskas Jan 21, 2026
c59b8f9
Merge branch 'main' into dev/jza/item_attributes_as_product_options
jzaksauskas Jan 21, 2026
ee826c4
Removed test scenario of checking restriction to have only 1 product …
jzaksauskas Jan 21, 2026
545db10
Added additioanal tests for Item Attributes as Prod. Options
jzaksauskas Jan 21, 2026
0170a98
Fix label formatting for item variant error messages and add caption …
jzaksauskas Jan 22, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/Apps/W1/Shopify/App/src/Base/Tables/ShpfyShop.Table.al
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

namespace Microsoft.Integration.Shopify;

using Microsoft.Inventory.Item.Attribute;
using Microsoft.Finance.Currency;
using Microsoft.Finance.GeneralLedger.Account;
using Microsoft.Finance.GeneralLedger.Setup;
Expand Down Expand Up @@ -300,6 +301,9 @@ table 30102 "Shpfy Shop"

trigger OnValidate()
begin
if "UoM as Variant" then
VerifyNoItemAttributesAsOptions();

if "UoM as Variant" and ("Option Name for UoM" = '') then
"Option Name for UoM" := 'Unit of Measure';
end;
Expand Down Expand Up @@ -1090,4 +1094,14 @@ table 30102 "Shpfy Shop"
end;
#pragma warning restore AL0432
#endif

local procedure VerifyNoItemAttributesAsOptions()
var
ItemAttribute: Record "Item Attribute";
UoMVariantUnavailableErr: Label 'UoM as Variant is unavailable due to existing Item Attributes marked as “As Option” which are utilized for Shopify Product Options.';
begin
ItemAttribute.SetRange("Shpfy Incl. in Product Sync", "Shpfy Incl. in Product Sync"::"As Option");
if not ItemAttribute.IsEmpty() then
Error(UoMVariantUnavailableErr);
end;
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,30 @@ codeunit 30343 "Shpfy Create Item As Variant"
internal procedure CreateVariantFromItem(var Item: Record "Item")
var
TempShopifyVariant: Record "Shpfy Variant" temporary;
ProductExport: Codeunit "Shpfy Product Export";
VariantOptionTok: Label 'Variant', Locked = true;
TitleOptionTok: Label 'Title', Locked = true;
begin
if Item.SystemId = ShopifyProduct."Item SystemId" then
exit;

CreateProduct.CreateTempShopifyVariantFromItem(Item, TempShopifyVariant);
TempShopifyVariant.Title := Item."No.";

if not ShopifyProduct."Has Variants" and (OptionName = 'Title') then begin
if not ShopifyProduct."Has Variants" and (OptionName = TitleOptionTok) then begin
// Shopify automatically deletes the default variant (Title) when adding a new one so first we need to update the default variant to have a different name (Variant)
UpdateProductOption('Variant');
TempShopifyVariant."Option 1 Name" := 'Variant';
UpdateProductOption(VariantOptionTok);
TempShopifyVariant."Option 1 Name" := VariantOptionTok;
end else
TempShopifyVariant."Option 1 Name" := CopyStr(OptionName, 1, MaxStrLen(TempShopifyVariant."Option 1 Name"));
TempShopifyVariant."Option 1 Value" := Item."No.";


if ShopifyProduct."Has Variants" and (OptionName <> VariantOptionTok) then begin
ProductExport.SetShop(Shop);
ProductExport.ValidateItemAttributesAsProductOptionsForNewVariant(TempShopifyVariant, Item, '', ShopifyProduct.Id);
end;

Events.OnAfterCreateTempShopifyVariant(Item, TempShopifyVariant);
TempShopifyVariant.Modify();

Expand All @@ -67,17 +76,13 @@ codeunit 30343 "Shpfy Create Item As Variant"
var
CommunicationMgt: Codeunit "Shpfy Communication Mgt.";
Options: Dictionary of [Text, Text];
MultipleOptionsErr: Label 'The product has more than one option. Items cannot be added as variants to a product with multiple options.';
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';
begin
if Shop."UoM as Variant" then
Error(UOMAsVariantEnabledErr, Shop.FieldCaption("UoM as Variant"));

Options := ProductApi.GetProductOptions(ShopifyProduct.Id);

if Options.Count > 1 then
Error(MultipleOptionsErr);

OptionId := CommunicationMgt.GetIdOfGId(Options.Keys.Get(1));
OptionName := Options.Values.Get(1);
end;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ codeunit 30174 "Shpfy Create Product"
TempShopifyVariant: Record "Shpfy Variant" temporary;
TempShopifyTag: Record "Shpfy Tag" temporary;
begin
if not ProductExport.CheckItemAttributesCompatibleForProductOptions(Item) then
exit;

CreateTempProduct(Item, TempShopifyProduct, TempShopifyVariant, TempShopifyTag);
if not VariantApi.FindShopifyProductVariant(TempShopifyProduct, TempShopifyVariant) then
ProductId := ProductApi.CreateProduct(TempShopifyProduct, TempShopifyVariant, TempShopifyTag)
Expand Down Expand Up @@ -164,6 +167,7 @@ codeunit 30174 "Shpfy Create Product"
end else
CreateTempShopifyVariantFromItem(Item, TempShopifyVariant);

ProductExport.FillProductOptionsForShopifyVariants(Item, TempShopifyVariant, TempShopifyProduct);
TempShopifyProduct.Insert(false);
Events.OnAfterCreateTempShopifyProduct(Item, TempShopifyProduct, TempShopifyVariant, TempShopifyTag);
end;
Expand Down
Loading
Loading