Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 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
4a00801
Refactored ValidateItemAttributesAsProductOptionsForNewVariant proced…
jzaksauskas Jan 26, 2026
b238ac4
Adjusted Add Item as Variant functioanlity by leaving default behavio…
jzaksauskas Jan 28, 2026
9ad85f9
Moved OptionId and OptionName assignment after product options verifi…
jzaksauskas Jan 28, 2026
34aabb6
Update src/Apps/W1/Shopify/App/src/Products/Enums/ShpfyInclInProductS…
onbuyuka Feb 10, 2026
ed7679c
Update src/Apps/W1/Shopify/App/src/Products/Table Extensions/ShpfyIte…
onbuyuka Feb 10, 2026
f8e53c3
Update src/Apps/W1/Shopify/App/src/Base/Tables/ShpfyShop.Table.al
onbuyuka Feb 10, 2026
130d8f5
Apply suggestion from @onbuyuka
onbuyuka Feb 10, 2026
1d50999
Apply suggestions from code review
onbuyuka Feb 10, 2026
622d783
Apply suggestion from @onbuyuka
onbuyuka Feb 10, 2026
d06c483
Add new range to app.json
onbuyuka Feb 10, 2026
b7d988a
Merge branch 'main' into dev/jza/item_attributes_as_product_options
onbuyuka Feb 10, 2026
899eea7
Apply suggestions from code review
onbuyuka Feb 10, 2026
c20ef9f
Apply suggestion from @onbuyuka
onbuyuka Feb 10, 2026
00d579d
Apply suggestion from @onbuyuka
onbuyuka Feb 10, 2026
8113745
Apply suggestion from @onbuyuka
onbuyuka Feb 10, 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 @@ -12,6 +12,7 @@ using Microsoft.Finance.SalesTax;
using Microsoft.Finance.VAT.Setup;
using Microsoft.Foundation.Address;
using Microsoft.Inventory.Item;
using Microsoft.Inventory.Item.Attribute;
using Microsoft.Inventory.Location;
using Microsoft.Sales.Customer;
using Microsoft.Sales.Pricing;
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 'You cannot enable this setting because one or more Item Attributes are configured with "Incl. in Product Sync" set to "As Option".';
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 @@ -6,6 +6,7 @@
namespace Microsoft.Integration.Shopify;

using Microsoft.Inventory.Item;
using Microsoft.Inventory.Item.Attribute;

codeunit 30343 "Shpfy Create Item As Variant"
{
Expand Down Expand Up @@ -33,21 +34,33 @@ codeunit 30343 "Shpfy Create Item As Variant"
/// <param name="Item">The item to be added as a variant.</param>
internal procedure CreateVariantFromItem(var Item: Record "Item")
var
ProductItem: Record Item;
TempShopifyVariant: Record "Shpfy Variant" temporary;
ProductExport: Codeunit "Shpfy Product Export";
ItemAttributeIds: List of [Integer];
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
// 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';
end else
TempShopifyVariant."Option 1 Name" := CopyStr(OptionName, 1, MaxStrLen(TempShopifyVariant."Option 1 Name"));
TempShopifyVariant."Option 1 Value" := Item."No.";
if ProductItem.GetBySystemId(ShopifyProduct."Item SystemId") then
ProductExport.GetItemAttributeIDsMarkedAsOption(ProductItem, ItemAttributeIds);

if ItemAttributeIds.Count = 0 then begin
if not ShopifyProduct."Has Variants" and (OptionName = 'Title') 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';
end else
TempShopifyVariant."Option 1 Name" := CopyStr(OptionName, 1, MaxStrLen(TempShopifyVariant."Option 1 Name"));
TempShopifyVariant."Option 1 Value" := Item."No.";
end else begin
ProductExport.SetShop(Shop);
if not ProductExport.ValidateItemAttributesAsProductOptionsForNewVariant(TempShopifyVariant, Item, '', ShopifyProduct.Id) then
exit;
end;

Events.OnAfterCreateTempShopifyVariant(Item, TempShopifyVariant);
TempShopifyVariant.Modify();
Expand All @@ -65,7 +78,10 @@ codeunit 30343 "Shpfy Create Item As Variant"
/// </summary>
internal procedure CheckProductAndShopSettings()
var
ProductItem: Record Item;
CommunicationMgt: Codeunit "Shpfy Communication Mgt.";
ProductExport: Codeunit "Shpfy Product Export";
ItemAttributeIds: List of [Integer];
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';
Expand All @@ -75,8 +91,14 @@ codeunit 30343 "Shpfy Create Item As Variant"

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

if Options.Count > 1 then
Error(MultipleOptionsErr);
if ProductItem.GetBySystemId(ShopifyProduct."Item SystemId") then
ProductExport.GetItemAttributeIDsMarkedAsOption(ProductItem, ItemAttributeIds);

if ItemAttributeIds.Count = 0 then begin
if Options.Count > 1 then
Error(MultipleOptionsErr);
end else
VerifyProductOptionsMatchesItemAttributes(Options, ProductItem);

OptionId := CommunicationMgt.GetIdOfGId(Options.Keys.Get(1));
OptionName := Options.Values.Get(1);
Expand All @@ -98,6 +120,28 @@ codeunit 30343 "Shpfy Create Item As Variant"
OptionName := NewOptionName;
end;

local procedure VerifyProductOptionsMatchesItemAttributes(Options: Dictionary of [Text, Text]; Item: Record Item)
var
ItemAttributeValueMapping: Record "Item Attribute Value Mapping";
ItemAttribute: Record "Item Attribute";
ShopifyOptionName: Text;
MissingItemAttributeErr: Label 'Item cannot be added as variant because the Shopify product option "%1" does not have a corresponding Item Attribute marked as "As Option" assigned to the parent Item.', Comment = '%1 - Shopify Option Name';
begin
foreach ShopifyOptionName in Options.Values do begin
ItemAttribute.SetRange(Name, ShopifyOptionName);
ItemAttribute.SetRange(Blocked, false);
ItemAttribute.SetRange("Shpfy Incl. in Product Sync", ItemAttribute."Shpfy Incl. in Product Sync"::"As Option");
if ItemAttribute.FindFirst() then begin
ItemAttributeValueMapping.SetRange("Table ID", Database::Item);
ItemAttributeValueMapping.SetRange("No.", Item."No.");
ItemAttributeValueMapping.SetRange("Item Attribute ID", ItemAttribute.ID);
if ItemAttributeValueMapping.IsEmpty() then
Error(MissingItemAttributeErr, ShopifyOptionName);
end else
Error(MissingItemAttributeErr, ShopifyOptionName);
end;
end;

local procedure SetShop(ShopCode: Code[20])
begin
Shop.Get(ShopCode);
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 @@ -161,6 +164,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