From b20646d6dc101f58bbf38d5a268b737b55946a4b Mon Sep 17 00:00:00 2001 From: Tine Staric Date: Mon, 17 Jun 2024 18:09:28 +0300 Subject: [PATCH 01/10] Extract GetVariantSKU case --- .../Codeunits/ShpfyCreateProduct.Codeunit.al | 90 ++++++------------- 1 file changed, 25 insertions(+), 65 deletions(-) diff --git a/Apps/W1/Shopify/app/src/Products/Codeunits/ShpfyCreateProduct.Codeunit.al b/Apps/W1/Shopify/app/src/Products/Codeunits/ShpfyCreateProduct.Codeunit.al index 307e45a4ea..bcbf8e520f 100644 --- a/Apps/W1/Shopify/app/src/Products/Codeunits/ShpfyCreateProduct.Codeunit.al +++ b/Apps/W1/Shopify/app/src/Products/Codeunits/ShpfyCreateProduct.Codeunit.al @@ -87,22 +87,7 @@ codeunit 30174 "Shpfy Create Product" ProductPriceCalc.CalcPrice(Item, ItemVariant.Code, ItemUnitofMeasure.Code, TempShopifyVariant."Unit Cost", TempShopifyVariant.Price, TempShopifyVariant."Compare at Price"); TempShopifyVariant.Title := ItemVariant.Description; TempShopifyVariant."Inventory Policy" := Shop."Default Inventory Policy"; - case Shop."SKU Mapping" of - Shop."SKU Mapping"::"Bar Code": - TempShopifyVariant.SKU := TempShopifyVariant.Barcode; - Shop."SKU Mapping"::"Item No.": - TempShopifyVariant.SKU := Item."No."; - Shop."SKU Mapping"::"Variant Code": - if ItemVariant.Code <> '' then - TempShopifyVariant.SKU := ItemVariant.Code; - Shop."SKU Mapping"::"Item No. + Variant Code": - if ItemVariant.Code <> '' then - TempShopifyVariant.SKU := Item."No." + Shop."SKU Field Separator" + ItemVariant.Code - else - TempShopifyVariant.SKU := Item."No."; - Shop."SKU Mapping"::"Vendor Item No.": - TempShopifyVariant.SKU := Item."Vendor Item No."; - end; + TempShopifyVariant.SKU := GetVariantSKU(TempShopifyVariant.Barcode, Item."No.", ItemVariant.Code, Item."Vendor Item No."); TempShopifyVariant."Tax Code" := Item."Tax Group Code"; TempShopifyVariant.Taxable := true; TempShopifyVariant.Weight := Item."Gross Weight"; @@ -125,22 +110,7 @@ codeunit 30174 "Shpfy Create Product" ProductPriceCalc.CalcPrice(Item, ItemVariant.Code, Item."Sales Unit of Measure", TempShopifyVariant."Unit Cost", TempShopifyVariant.Price, TempShopifyVariant."Compare at Price"); TempShopifyVariant.Title := ItemVariant.Description; TempShopifyVariant."Inventory Policy" := Shop."Default Inventory Policy"; - case Shop."SKU Mapping" of - Shop."SKU Mapping"::"Bar Code": - TempShopifyVariant.SKU := TempShopifyVariant.Barcode; - Shop."SKU Mapping"::"Item No.": - TempShopifyVariant.SKU := Item."No."; - Shop."SKU Mapping"::"Variant Code": - if ItemVariant.Code <> '' then - TempShopifyVariant.SKU := ItemVariant.Code; - Shop."SKU Mapping"::"Item No. + Variant Code": - if ItemVariant.Code <> '' then - TempShopifyVariant.SKU := Item."No." + Shop."SKU Field Separator" + ItemVariant.Code - else - TempShopifyVariant.SKU := Item."No."; - Shop."SKU Mapping"::"Vendor Item No.": - TempShopifyVariant.SKU := CopyStr(GetVendorItemNo(Item."No.", ItemVariant.Code, Item."Sales Unit of Measure"), 1, MaxStrLen(TempShopifyVariant.SKU)); - end; + TempShopifyVariant.SKU := GetVariantSKU(TempShopifyVariant.Barcode, Item."No.", ItemVariant.Code, GetVendorItemNo(Item."No.", ItemVariant.Code, Item."Sales Unit of Measure")); TempShopifyVariant."Tax Code" := Item."Tax Group Code"; TempShopifyVariant.Taxable := true; TempShopifyVariant.Weight := Item."Gross Weight"; @@ -165,22 +135,7 @@ codeunit 30174 "Shpfy Create Product" ProductPriceCalc.CalcPrice(Item, '', ItemUnitofMeasure.Code, TempShopifyVariant."Unit Cost", TempShopifyVariant.Price, TempShopifyVariant."Compare at Price"); TempShopifyVariant.Title := Item.Description; TempShopifyVariant."Inventory Policy" := Shop."Default Inventory Policy"; - case Shop."SKU Mapping" of - Shop."SKU Mapping"::"Bar Code": - TempShopifyVariant.SKU := TempShopifyVariant.Barcode; - Shop."SKU Mapping"::"Item No.": - TempShopifyVariant.SKU := Item."No."; - Shop."SKU Mapping"::"Variant Code": - if ItemVariant.Code <> '' then - TempShopifyVariant.SKU := ItemVariant.Code; - SHop."SKU Mapping"::"Item No. + Variant Code": - if ItemVariant.Code <> '' then - TempShopifyVariant.SKU := Item."No." + Shop."SKU Field Separator" + ItemVariant.Code - else - TempShopifyVariant.SKU := Item."No."; - Shop."SKU Mapping"::"Vendor Item No.": - TempShopifyVariant.SKU := Item."Vendor Item No."; - end; + TempShopifyVariant.SKU := GetVariantSKU(TempShopifyVariant.Barcode, Item."No.", '', Item."Vendor Item No."); TempShopifyVariant."Tax Code" := Item."Tax Group Code"; TempShopifyVariant.Taxable := true; TempShopifyVariant.Weight := Item."Gross Weight"; @@ -198,22 +153,7 @@ codeunit 30174 "Shpfy Create Product" ProductPriceCalc.CalcPrice(Item, '', Item."Sales Unit of Measure", TempShopifyVariant."Unit Cost", TempShopifyVariant.Price, TempShopifyVariant."Compare at Price"); TempShopifyVariant.Title := ItemVariant.Description; TempShopifyVariant."Inventory Policy" := Shop."Default Inventory Policy"; - case Shop."SKU Mapping" of - Shop."SKU Mapping"::"Bar Code": - TempShopifyVariant.SKU := TempShopifyVariant.Barcode; - Shop."SKU Mapping"::"Item No.": - TempShopifyVariant.SKU := Item."No."; - Shop."SKU Mapping"::"Variant Code": - if ItemVariant.Code <> '' then - TempShopifyVariant.SKU := ItemVariant.Code; - SHop."SKU Mapping"::"Item No. + Variant Code": - if ItemVariant.Code <> '' then - TempShopifyVariant.SKU := Item."No." + Shop."SKU Field Separator" + ItemVariant.Code - else - TempShopifyVariant.SKU := Item."No."; - Shop."SKU Mapping"::"Vendor Item No.": - TempShopifyVariant.SKU := Item."Vendor Item No."; - end; + TempShopifyVariant.SKU := GetVariantSKU(TempShopifyVariant.Barcode, Item."No.", ItemVariant.Code, Item."Vendor Item No."); TempShopifyVariant."Tax Code" := Item."Tax Group Code"; TempShopifyVariant.Taxable := true; TempShopifyVariant.Weight := Item."Gross Weight"; @@ -247,7 +187,7 @@ codeunit 30174 "Shpfy Create Product" /// Parameter of type Code[10]. /// Parameter of type Code[10]. /// Return value of type Text. - local procedure GetVendorItemNo(ItemNo: Code[20]; VariantCode: Code[10]; UoM: Code[10]): Text; + local procedure GetVendorItemNo(ItemNo: Code[20]; VariantCode: Code[10]; UoM: Code[10]): Code[50]; var Item: Record Item; ItemReferenceMgt: Codeunit "Shpfy Item Reference Mgt."; @@ -256,6 +196,26 @@ codeunit 30174 "Shpfy Create Product" exit(ItemReferenceMgt.GetItemReference(ItemNo, VariantCode, UoM, "Item Reference Type"::Vendor, Item."Vendor No.")); end; + local procedure GetVariantSKU(BarCode: Text[50]; ItemNo: Text[20]; VariantCode: Text[10]; VendorItemNo: Text[50]): Text[50] + begin + case Shop."SKU Mapping" of + Shop."SKU Mapping"::"Bar Code": + exit(BarCode); + Shop."SKU Mapping"::"Item No.": + exit(ItemNo); + Shop."SKU Mapping"::"Variant Code": + if VariantCode <> '' then + exit(VariantCode); + Shop."SKU Mapping"::"Item No. + Variant Code": + if VariantCode <> '' then + exit(ItemNo + Shop."SKU Field Separator" + VariantCode) + else + exit(ItemNo); + Shop."SKU Mapping"::"Vendor Item No.": + exit(VendorItemNo); + end; + end; + /// /// Set Shop. /// From 965b3a9f04621ca1b0733296c20b67e737ed9faf Mon Sep 17 00:00:00 2001 From: Tine Staric Date: Wed, 19 Jun 2024 12:42:17 +0300 Subject: [PATCH 02/10] Extract Create Shpfy Variant from Item to an internal procedure --- .../Codeunits/ShpfyCreateProduct.Codeunit.al | 41 +++++++++++-------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/Apps/W1/Shopify/app/src/Products/Codeunits/ShpfyCreateProduct.Codeunit.al b/Apps/W1/Shopify/app/src/Products/Codeunits/ShpfyCreateProduct.Codeunit.al index bcbf8e520f..908921f62c 100644 --- a/Apps/W1/Shopify/app/src/Products/Codeunits/ShpfyCreateProduct.Codeunit.al +++ b/Apps/W1/Shopify/app/src/Products/Codeunits/ShpfyCreateProduct.Codeunit.al @@ -146,24 +146,11 @@ codeunit 30174 "Shpfy Create Product" TempShopifyVariant."UoM Option Id" := 1; TempShopifyVariant.Insert(false); until ItemUnitofMeasure.Next() = 0; - end else begin - Clear(TempShopifyVariant); - TempShopifyVariant."Available For Sales" := true; - TempShopifyVariant.Barcode := CopyStr(GetBarcode(Item."No.", '', Item."Sales Unit of Measure"), 1, MaxStrLen(TempShopifyVariant.Barcode)); - ProductPriceCalc.CalcPrice(Item, '', Item."Sales Unit of Measure", TempShopifyVariant."Unit Cost", TempShopifyVariant.Price, TempShopifyVariant."Compare at Price"); - TempShopifyVariant.Title := ItemVariant.Description; - TempShopifyVariant."Inventory Policy" := Shop."Default Inventory Policy"; - TempShopifyVariant.SKU := GetVariantSKU(TempShopifyVariant.Barcode, Item."No.", ItemVariant.Code, Item."Vendor Item No."); - TempShopifyVariant."Tax Code" := Item."Tax Group Code"; - TempShopifyVariant.Taxable := true; - TempShopifyVariant.Weight := Item."Gross Weight"; - TempShopifyVariant."Shop Code" := Shop.Code; - TempShopifyVariant."Item SystemId" := Item.SystemId; - TempShopifyVariant.Insert(false); - end; + end else + CreateTempShopifyVariantFromItem(Item, TempShopifyVariant); + TempShopifyProduct.Insert(false); Events.OnAfterCreateTempShopifyProduct(Item, TempShopifyProduct, TempShopifyVariant, TempShopifyTag); - end; /// @@ -216,6 +203,28 @@ codeunit 30174 "Shpfy Create Product" end; end; + /// + /// Creates a temporary Shopify variant with information from an item. + /// + /// The item to create the variant from. + /// The temporary Shopify variant record set where the variant will be inserted. + internal procedure CreateTempShopifyVariantFromItem(Item: Record Item; var TempShopifyVariant: Record "Shpfy Variant" temporary) + begin + Clear(TempShopifyVariant); + TempShopifyVariant."Available For Sales" := true; + TempShopifyVariant.Barcode := CopyStr(GetBarcode(Item."No.", '', Item."Sales Unit of Measure"), 1, MaxStrLen(TempShopifyVariant.Barcode)); + ProductPriceCalc.CalcPrice(Item, '', Item."Sales Unit of Measure", TempShopifyVariant."Unit Cost", TempShopifyVariant.Price, TempShopifyVariant."Compare at Price"); + TempShopifyVariant.Title := ''; + TempShopifyVariant."Inventory Policy" := Shop."Default Inventory Policy"; + TempShopifyVariant.SKU := GetVariantSKU(TempShopifyVariant.Barcode, Item."No.", '', Item."Vendor Item No."); + TempShopifyVariant."Tax Code" := Item."Tax Group Code"; + TempShopifyVariant.Taxable := true; + TempShopifyVariant.Weight := Item."Gross Weight"; + TempShopifyVariant."Shop Code" := Shop.Code; + TempShopifyVariant."Item SystemId" := Item.SystemId; + TempShopifyVariant.Insert(false); + end; + /// /// Set Shop. /// From 203553e48680c5266bae6fb5aaeb9065dfd53f34 Mon Sep 17 00:00:00 2001 From: Tine Staric Date: Wed, 19 Jun 2024 14:52:01 +0300 Subject: [PATCH 03/10] Bump API Version --- .../app/src/Base/Codeunits/ShpfyCommunicationMgt.Codeunit.al | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Apps/W1/Shopify/app/src/Base/Codeunits/ShpfyCommunicationMgt.Codeunit.al b/Apps/W1/Shopify/app/src/Base/Codeunits/ShpfyCommunicationMgt.Codeunit.al index 4be94bfe71..dfd9c859b2 100644 --- a/Apps/W1/Shopify/app/src/Base/Codeunits/ShpfyCommunicationMgt.Codeunit.al +++ b/Apps/W1/Shopify/app/src/Base/Codeunits/ShpfyCommunicationMgt.Codeunit.al @@ -17,7 +17,7 @@ codeunit 30103 "Shpfy Communication Mgt." CommunicationEvents: Codeunit "Shpfy Communication Events"; GraphQLQueries: Codeunit "Shpfy GraphQL Queries"; NextExecutionTime: DateTime; - VersionTok: Label '2024-01', Locked = true; + VersionTok: Label '2024-04', Locked = true; OutgoingRequestsNotEnabledConfirmLbl: Label 'Importing data to your Shopify shop is not enabled, do you want to go to shop card to enable?'; OutgoingRequestsNotEnabledErr: Label 'Importing data to your Shopify shop is not enabled, navigate to shop card to enable.'; IsTestInProgress: Boolean; From cf122f5400cf32bdbb5486327a0df31b9d18202d Mon Sep 17 00:00:00 2001 From: Tine Staric Date: Wed, 19 Jun 2024 14:52:28 +0300 Subject: [PATCH 04/10] Add Action for adding items as variants to existing shpfy products --- .../ShpfyGQLGetProductOptions.Codeunit.al | 27 ++++ .../ShpfyGQLProductOptionUpdate.Codeunit.al | 27 ++++ .../ShpfyGQLProductVariantDelete.Codeunit.al | 27 ++++ .../GraphQL/Enums/ShpfyGraphQLType.Enum.al | 15 +++ .../ShpfyCreateItemAsVariant.Codeunit.al | 95 +++++++++++++++ .../Codeunits/ShpfyCreateProduct.Codeunit.al | 3 +- .../Codeunits/ShpfyProductAPI.Codeunit.al | 37 ++++++ .../Codeunits/ShpfyVariantAPI.Codeunit.al | 27 +++- .../src/Products/Pages/ShpfyVariants.Page.al | 20 +++ .../Reports/ShpfyAddItemAsVariant.Report.al | 115 ++++++++++++++++++ 10 files changed, 387 insertions(+), 6 deletions(-) create mode 100644 Apps/W1/Shopify/app/src/GraphQL/Codeunits/ShpfyGQLGetProductOptions.Codeunit.al create mode 100644 Apps/W1/Shopify/app/src/GraphQL/Codeunits/ShpfyGQLProductOptionUpdate.Codeunit.al create mode 100644 Apps/W1/Shopify/app/src/GraphQL/Codeunits/ShpfyGQLProductVariantDelete.Codeunit.al create mode 100644 Apps/W1/Shopify/app/src/Products/Codeunits/ShpfyCreateItemAsVariant.Codeunit.al create mode 100644 Apps/W1/Shopify/app/src/Products/Reports/ShpfyAddItemAsVariant.Report.al diff --git a/Apps/W1/Shopify/app/src/GraphQL/Codeunits/ShpfyGQLGetProductOptions.Codeunit.al b/Apps/W1/Shopify/app/src/GraphQL/Codeunits/ShpfyGQLGetProductOptions.Codeunit.al new file mode 100644 index 0000000000..85de24721b --- /dev/null +++ b/Apps/W1/Shopify/app/src/GraphQL/Codeunits/ShpfyGQLGetProductOptions.Codeunit.al @@ -0,0 +1,27 @@ +namespace Microsoft.Integration.Shopify; + +/// +/// Codeunit Shpfy GQL GetProductOptions (ID 30168) implements Interface Shpfy IGraphQL. +/// +codeunit 30168 "Shpfy GQL GetProductOptions" implements "Shpfy IGraphQL" +{ + Access = Internal; + + /// + /// GetGraphQL. + /// + /// Return value of type Text. + internal procedure GetGraphQL(): Text + begin + exit('{"query":"{product(id: \"gid://shopify/Product/{{ProductId}}\") {id title options {id name}}}"}'); + end; + + /// + /// GetExpectedCost. + /// + /// Return value of type Integer. + internal procedure GetExpectedCost(): Integer + begin + exit(2); + end; +} diff --git a/Apps/W1/Shopify/app/src/GraphQL/Codeunits/ShpfyGQLProductOptionUpdate.Codeunit.al b/Apps/W1/Shopify/app/src/GraphQL/Codeunits/ShpfyGQLProductOptionUpdate.Codeunit.al new file mode 100644 index 0000000000..d45078353e --- /dev/null +++ b/Apps/W1/Shopify/app/src/GraphQL/Codeunits/ShpfyGQLProductOptionUpdate.Codeunit.al @@ -0,0 +1,27 @@ +namespace Microsoft.Integration.Shopify; + +/// +/// Codeunit Shpfy GQL ProductOptionUpdate (ID 30213) implements Interface Shpfy IGraphQL. +/// +codeunit 30213 "Shpfy GQL ProductOptionUpdate" implements "Shpfy IGraphQL" +{ + Access = Internal; + + /// + /// GetGraphQL. + /// + /// Return value of type Text. + internal procedure GetGraphQL(): Text + begin + exit('{"query": "mutation { productOptionUpdate(productId: \"gid://shopify/Product/{{ProductId}}\", option: {id: \"{{OptionId}}\", name: \"{{OptionName}}\"}) { product { id options { id name }} userErrors {field message}}}"}'); + end; + + /// + /// GetExpectedCost. + /// + /// Return value of type Integer. + internal procedure GetExpectedCost(): Integer + begin + exit(10); + end; +} diff --git a/Apps/W1/Shopify/app/src/GraphQL/Codeunits/ShpfyGQLProductVariantDelete.Codeunit.al b/Apps/W1/Shopify/app/src/GraphQL/Codeunits/ShpfyGQLProductVariantDelete.Codeunit.al new file mode 100644 index 0000000000..7b387c817b --- /dev/null +++ b/Apps/W1/Shopify/app/src/GraphQL/Codeunits/ShpfyGQLProductVariantDelete.Codeunit.al @@ -0,0 +1,27 @@ +namespace Microsoft.Integration.Shopify; + +/// +/// Codeunit Shpfy GQL ProductVariantDelete (ID 30159) implements Interface Shpfy IGraphQL. +/// +codeunit 30159 "Shpfy GQL ProductVariantDelete" implements "Shpfy IGraphQL" +{ + Access = Internal; + + /// + /// GetGraphQL. + /// + /// Return value of type Text. + internal procedure GetGraphQL(): Text + begin + exit('{"query":"mutation {productVariantDelete(id: \"gid://shopify/ProductVariant/{{VariantId}}\") {deletedProductVariantId userErrors{field message}}}"}'); + end; + + /// + /// GetExpectedCost. + /// + /// Return value of type Integer. + internal procedure GetExpectedCost(): Integer + begin + exit(10); + end; +} diff --git a/Apps/W1/Shopify/app/src/GraphQL/Enums/ShpfyGraphQLType.Enum.al b/Apps/W1/Shopify/app/src/GraphQL/Enums/ShpfyGraphQLType.Enum.al index 4315a4f5e6..4af6ee93e0 100644 --- a/Apps/W1/Shopify/app/src/GraphQL/Enums/ShpfyGraphQLType.Enum.al +++ b/Apps/W1/Shopify/app/src/GraphQL/Enums/ShpfyGraphQLType.Enum.al @@ -400,4 +400,19 @@ enum 30111 "Shpfy GraphQL Type" implements "Shpfy IGraphQL" Caption = 'Get Next Catalog Products'; Implementation = "Shpfy IGraphQL" = "Shpfy GQL NextCatalogProducts"; } + value(78; ProductVariantDelete) + { + Caption = 'Product Variant Delete'; + Implementation = "Shpfy IGraphQL" = "Shpfy GQL ProductVariantDelete"; + } + value(79; GetProductOptions) + { + Caption = 'Get Product Options'; + Implementation = "Shpfy IGraphQL" = "Shpfy GQL GetProductOptions"; + } + value(80; ProductOptionUpdate) + { + Caption = 'Product Option Update'; + Implementation = "Shpfy IGraphQL" = "Shpfy GQL ProductOptionUpdate"; + } } diff --git a/Apps/W1/Shopify/app/src/Products/Codeunits/ShpfyCreateItemAsVariant.Codeunit.al b/Apps/W1/Shopify/app/src/Products/Codeunits/ShpfyCreateItemAsVariant.Codeunit.al new file mode 100644 index 0000000000..a9866d547c --- /dev/null +++ b/Apps/W1/Shopify/app/src/Products/Codeunits/ShpfyCreateItemAsVariant.Codeunit.al @@ -0,0 +1,95 @@ +namespace Microsoft.Integration.Shopify; + +using Microsoft.Inventory.Item; + +codeunit 30105 "Shpfy Create Item As Variant" +{ + TableNo = Item; + + var + Shop: Record "Shpfy Shop"; + ShopifyProduct: Record "Shpfy Product"; + CreateProduct: Codeunit "Shpfy Create Product"; + VariantApi: Codeunit "Shpfy Variant API"; + ProductApi: Codeunit "Shpfy Product API"; + RenameProductOption: Boolean; + DefaultVariantId: BigInteger; + + trigger OnRun() + begin + CreateVariantFromItem(Rec); + end; + + /// + /// Creates a variant from a given item and adds it to the parent product. + /// + /// The item to be added as a variant. + internal procedure CreateVariantFromItem(var Item: Record "Item") + var + TempShopifyVariant: Record "Shpfy Variant" temporary; + begin + CreateProduct.CreateTempShopifyVariantFromItem(Item, TempShopifyVariant); + TempShopifyVariant."Product Id" := ShopifyProduct."Id"; + TempShopifyVariant.Title := Item.Description; + TempShopifyVariant."Option 1 Name" := 'Item'; + TempShopifyVariant."Option 1 Value" := Item."No."; + + if VariantApi.AddProductVariant(TempShopifyVariant) then begin + ShopifyProduct."Has Variants" := true; + ShopifyProduct.Modify(true); + end; + end; + + /// + /// Checks if the product has only the default variant assigned and prepares the variant for deletion. + /// + internal procedure CheckIfProductHasDefaultVariant() + var + ProductVariantIds: Dictionary of [BigInteger, DateTime]; + begin + if not ShopifyProduct."Has Variants" then begin + RenameProductOption := true; + VariantApi.RetrieveShopifyProductVariantIds(ShopifyProduct, ProductVariantIds); + DefaultVariantId := ProductVariantIds.Keys.Get(1); + end; + end; + + /// + /// Removes the default variant and renames the option if the product had only the default variant. + /// + internal procedure RemoveDefaultVariantAndRenameOption() + var + ShopifyVariant: Record "Shpfy Variant"; + Options: Dictionary of [Text, Text]; + begin + // If new variants were added to the product that only had the default variant, + // we need to remove the default variant from Shopify and BC and rename the option. + if RenameProductOption and ShopifyProduct."Has Variants" then begin + VariantApi.DeleteProductVariant(DefaultVariantId); + if ShopifyVariant.Get(DefaultVariantId) then + ShopifyVariant.Delete(true); + + Options := ProductApi.GetProductOptions(ShopifyProduct.Id); + ProductApi.UpdateProductOption(ShopifyProduct.Id, Options.Keys.Get(1), 'Item'); + end; + end; + + /// + /// Sets the parent product to which the variant will be added. + /// + /// The parent Shopify product ID. + internal procedure SetParentProduct(ShopifyProductId: BigInteger) + begin + ShopifyProduct.Get(ShopifyProductId); + SetShop(ShopifyProduct."Shop Code"); + end; + + local procedure SetShop(ShopCode: Code[20]) + begin + Shop.Get(ShopCode); + VariantApi.SetShop(Shop); + ProductApi.SetShop(Shop); + CreateProduct.SetShop(Shop); + end; + +} \ No newline at end of file diff --git a/Apps/W1/Shopify/app/src/Products/Codeunits/ShpfyCreateProduct.Codeunit.al b/Apps/W1/Shopify/app/src/Products/Codeunits/ShpfyCreateProduct.Codeunit.al index 908921f62c..fc276ff98f 100644 --- a/Apps/W1/Shopify/app/src/Products/Codeunits/ShpfyCreateProduct.Codeunit.al +++ b/Apps/W1/Shopify/app/src/Products/Codeunits/ShpfyCreateProduct.Codeunit.al @@ -127,6 +127,7 @@ codeunit 30174 "Shpfy Create Product" ItemUnitofMeasure.SetRange("Item No.", Item."No."); if ItemUnitofMeasure.FindSet(false) then repeat + TempShopifyProduct."Has Variants" := true; Id += 1; Clear(TempShopifyVariant); TempShopifyVariant.Id := Id; @@ -214,7 +215,7 @@ codeunit 30174 "Shpfy Create Product" TempShopifyVariant."Available For Sales" := true; TempShopifyVariant.Barcode := CopyStr(GetBarcode(Item."No.", '', Item."Sales Unit of Measure"), 1, MaxStrLen(TempShopifyVariant.Barcode)); ProductPriceCalc.CalcPrice(Item, '', Item."Sales Unit of Measure", TempShopifyVariant."Unit Cost", TempShopifyVariant.Price, TempShopifyVariant."Compare at Price"); - TempShopifyVariant.Title := ''; + TempShopifyVariant.Title := ''; // Title will be assigned to "Default Title" in Shopify as no Options are set. TempShopifyVariant."Inventory Policy" := Shop."Default Inventory Policy"; TempShopifyVariant.SKU := GetVariantSKU(TempShopifyVariant.Barcode, Item."No.", '', Item."Vendor Item No."); TempShopifyVariant."Tax Code" := Item."Tax Group Code"; diff --git a/Apps/W1/Shopify/app/src/Products/Codeunits/ShpfyProductAPI.Codeunit.al b/Apps/W1/Shopify/app/src/Products/Codeunits/ShpfyProductAPI.Codeunit.al index 8e7042e9a4..c8ffcf7dc0 100644 --- a/Apps/W1/Shopify/app/src/Products/Codeunits/ShpfyProductAPI.Codeunit.al +++ b/Apps/W1/Shopify/app/src/Products/Codeunits/ShpfyProductAPI.Codeunit.al @@ -608,4 +608,41 @@ codeunit 30176 "Shpfy Product API" begin exit(Value.Names.Get(Value.Ordinals.IndexOf(Value.AsInteger())).ToUpper()); end; + + /// + /// Gets all the Product Options for a product. + /// + /// Shopify product ID for which the options are to be retrieved. + /// Dictionary of option IDs and option names. + internal procedure GetProductOptions(ShopifyProductId: BigInteger) Options: Dictionary of [text, Text] + var + Parameters: Dictionary of [Text, Text]; + JResponse: JsonToken; + JOptions: JsonArray; + JOption: JsonToken; + begin + Parameters.Add('ProductId', Format(ShopifyProductId)); + JResponse := CommunicationMgt.ExecuteGraphQL(Enum::"Shpfy GraphQL Type"::GetProductOptions, Parameters); + + JsonHelper.GetJsonArray(JResponse, JOptions, 'data.product.options'); + foreach JOption in JOptions do + Options.Add(JsonHelper.GetValueAsText(JOption, 'id'), JsonHelper.GetValueAsText(JOption, 'name')); + end; + + /// + /// Updates the name of a Product Option. + /// + /// Shopify product ID for which the option is to be updated. + /// Option ID to be updated. + /// New name for the option. + internal procedure UpdateProductOption(ShopifyProductId: BigInteger; OptionId: Text; NewOptionName: Text) + var + Parameters: Dictionary of [Text, Text]; + begin + Parameters.Add('ProductId', Format(ShopifyProductId)); + Parameters.Add('OptionId', OptionId); + Parameters.Add('OptionName', NewOptionName); + + CommunicationMgt.ExecuteGraphQL(Enum::"Shpfy GraphQL Type"::ProductOptionUpdate, Parameters); + end; } \ No newline at end of file diff --git a/Apps/W1/Shopify/app/src/Products/Codeunits/ShpfyVariantAPI.Codeunit.al b/Apps/W1/Shopify/app/src/Products/Codeunits/ShpfyVariantAPI.Codeunit.al index f8829bff70..6f69b2787d 100644 --- a/Apps/W1/Shopify/app/src/Products/Codeunits/ShpfyVariantAPI.Codeunit.al +++ b/Apps/W1/Shopify/app/src/Products/Codeunits/ShpfyVariantAPI.Codeunit.al @@ -55,11 +55,12 @@ codeunit 30189 "Shpfy Variant API" end; end; - /// - /// Add Product Variant. + /// + /// Adds a product variant to Shopify. /// - /// Parameter of type Record "Shopify Variant". - internal procedure AddProductVariant(var ShopifyVariant: Record "Shpfy Variant") + /// Shopify Variant record to add. + /// True if the variant was added successfully; otherwise, false. + internal procedure AddProductVariant(var ShopifyVariant: Record "Shpfy Variant"): Boolean var ShopLocation: Record "Shpfy Shop Location"; NewShopifyVariant: Record "Shpfy Variant"; @@ -140,8 +141,12 @@ codeunit 30189 "Shpfy Variant API" JResponse := CommunicationMgt.ExecuteGraphQL(GraphQuery.ToText()); NewShopifyVariant := ShopifyVariant; NewShopifyVariant.Id := JsonHelper.GetValueAsBigInteger(JResponse, 'data.productVariantCreate.productVariant.legacyResourceId'); - if NewShopifyVariant.Id > 0 then + if NewShopifyVariant.Id > 0 then begin NewShopifyVariant.Insert(); + exit(true); + end; + + exit(false); end; /// @@ -593,4 +598,16 @@ codeunit 30189 "Shpfy Variant API" if JsonHelper.GetJsonArray(JNode, JMetafields, 'edges') then foreach JItem in JMetafields do; end; + + /// + /// Deletes a product variant from Shopify. + /// + /// Id of the Shopify variant to delete. + internal procedure DeleteProductVariant(ShopifyVariantId: BigInteger) + var + Parameters: Dictionary of [Text, Text]; + begin + Parameters.Add('VariantId', Format(ShopifyVariantId)); + CommunicationMgt.ExecuteGraphQL(Enum::"Shpfy GraphQL Type"::ProductVariantDelete, Parameters); + end; } \ No newline at end of file diff --git a/Apps/W1/Shopify/app/src/Products/Pages/ShpfyVariants.Page.al b/Apps/W1/Shopify/app/src/Products/Pages/ShpfyVariants.Page.al index 73fa6d2127..3291b4e345 100644 --- a/Apps/W1/Shopify/app/src/Products/Pages/ShpfyVariants.Page.al +++ b/Apps/W1/Shopify/app/src/Products/Pages/ShpfyVariants.Page.al @@ -213,6 +213,26 @@ page 30127 "Shpfy Variants" end; end; } + action(AddItemsAsVariants) + { + ApplicationArea = All; + Caption = 'Add Items as Shopify Variants'; + Image = AddAction; + ToolTip = 'Add existing items as new Shopify variants for the selected parent product.'; + + trigger OnAction() + var + AddItemAsVariant: Report "Shpfy Add Item As Variant"; + ParentProductId: BigInteger; + begin + Rec.FilterGroup(4); + Evaluate(ParentProductId, Rec.GetFilter("Product Id")); + Rec.FilterGroup(0); + + AddItemAsVariant.SetParentProduct(ParentProductId); + AddItemAsVariant.Run(); + end; + } } } } diff --git a/Apps/W1/Shopify/app/src/Products/Reports/ShpfyAddItemAsVariant.Report.al b/Apps/W1/Shopify/app/src/Products/Reports/ShpfyAddItemAsVariant.Report.al new file mode 100644 index 0000000000..3d4731c3a9 --- /dev/null +++ b/Apps/W1/Shopify/app/src/Products/Reports/ShpfyAddItemAsVariant.Report.al @@ -0,0 +1,115 @@ +namespace Microsoft.Integration.Shopify; + +using Microsoft.Inventory.Item; + +/// +/// A report to add items as variants to a parent product. +/// +report 30117 "Shpfy Add Item As Variant" +{ + ApplicationArea = All; + Caption = 'Add Item as Shopify Variant'; + ProcessingOnly = true; + UsageCategory = Administration; + + dataset + { + dataitem(Item; Item) + { + RequestFilterFields = "No."; + trigger OnPreDataItem() + begin + if ParentProductNo = 0 then + Error(MissingProductErr); + + Clear(CreateItemAsVariant); + CreateItemAsVariant.SetParentProduct(ParentProductNo); + CreateItemAsVariant.CheckIfProductHasDefaultVariant(); + + if GuiAllowed then begin + CurrItemNo := Item."No."; + ProcessDialog.Open(ProcessMsg, CurrItemNo); + ProcessDialog.Update(); + end; + end; + + trigger OnAfterGetRecord() + begin + if GuiAllowed then begin + CurrItemNo := Item."No."; + ProcessDialog.Update(); + end; + + CreateItemAsVariant.Run(Item); + end; + + trigger OnPostDataItem() + begin + CreateItemAsVariant.RemoveDefaultVariantAndRenameOption(); + + if GuiAllowed then + ProcessDialog.Close(); + end; + } + } + + requestpage + { + SaveValues = true; + layout + { + area(Content) + { + group(ShopFilter) + { + Caption = 'Options'; + field(Shop; ShopCode) + { + ApplicationArea = All; + Caption = 'Shop Code'; + Editable = false; + ToolTip = 'Specifies the Shopify Shop.'; + ShowMandatory = true; + } + field(ParentItemNo; ParentProductNo) + { + ApplicationArea = All; + TableRelation = "Shpfy Product"; + LookupPageId = "Shpfy Products"; + Lookup = true; + Caption = 'Parent Item No.'; + ToolTip = 'Specifies the parent item number to which the variants will be added.'; + ShowMandatory = true; + + trigger OnValidate() + begin + SetParentProduct(ParentProductNo); + end; + } + } + } + } + } + + var + CreateItemAsVariant: Codeunit "Shpfy Create Item As Variant"; + ShopCode: Code[20]; + ParentProductNo: BigInteger; + CurrItemNo: Code[20]; + ProcessDialog: Dialog; + ProcessMsg: Label 'Adding item #1####################', Comment = '#1 = Item no.'; + MissingProductErr: Label 'You must select a parent product to add the items as variants to.'; + + /// + /// Sets the parent product to which items will be added as variants. + /// + /// The parent product number. + internal procedure SetParentProduct(NewParentProductNo: BigInteger) + var + ShopifyProduct: Record "Shpfy Product"; + begin + ParentProductNo := NewParentProductNo; + ShopifyProduct.Get(ParentProductNo); + ShopCode := ShopifyProduct."Shop Code"; + end; +} \ No newline at end of file From e74253c9d897a0317362a3e27f40b1692aa4bf23 Mon Sep 17 00:00:00 2001 From: Tine Staric Date: Thu, 20 Jun 2024 09:49:47 +0300 Subject: [PATCH 05/10] Revert API Version --- .../app/src/Base/Codeunits/ShpfyCommunicationMgt.Codeunit.al | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Apps/W1/Shopify/app/src/Base/Codeunits/ShpfyCommunicationMgt.Codeunit.al b/Apps/W1/Shopify/app/src/Base/Codeunits/ShpfyCommunicationMgt.Codeunit.al index dfd9c859b2..4be94bfe71 100644 --- a/Apps/W1/Shopify/app/src/Base/Codeunits/ShpfyCommunicationMgt.Codeunit.al +++ b/Apps/W1/Shopify/app/src/Base/Codeunits/ShpfyCommunicationMgt.Codeunit.al @@ -17,7 +17,7 @@ codeunit 30103 "Shpfy Communication Mgt." CommunicationEvents: Codeunit "Shpfy Communication Events"; GraphQLQueries: Codeunit "Shpfy GraphQL Queries"; NextExecutionTime: DateTime; - VersionTok: Label '2024-04', Locked = true; + VersionTok: Label '2024-01', Locked = true; OutgoingRequestsNotEnabledConfirmLbl: Label 'Importing data to your Shopify shop is not enabled, do you want to go to shop card to enable?'; OutgoingRequestsNotEnabledErr: Label 'Importing data to your Shopify shop is not enabled, navigate to shop card to enable.'; IsTestInProgress: Boolean; From 7e63a33e06605f766f81972f0ca95752c89cf8d7 Mon Sep 17 00:00:00 2001 From: Tine Staric Date: Thu, 20 Jun 2024 12:00:50 +0300 Subject: [PATCH 06/10] Remove Option update, add gate keepers --- .../ShpfyGQLProductOptionUpdate.Codeunit.al | 27 ------------ .../GraphQL/Enums/ShpfyGraphQLType.Enum.al | 5 --- .../ShpfyCreateItemAsVariant.Codeunit.al | 44 ++++++++++++------- .../Codeunits/ShpfyProductAPI.Codeunit.al | 17 ------- .../Reports/ShpfyAddItemAsVariant.Report.al | 5 ++- 5 files changed, 32 insertions(+), 66 deletions(-) delete mode 100644 Apps/W1/Shopify/app/src/GraphQL/Codeunits/ShpfyGQLProductOptionUpdate.Codeunit.al diff --git a/Apps/W1/Shopify/app/src/GraphQL/Codeunits/ShpfyGQLProductOptionUpdate.Codeunit.al b/Apps/W1/Shopify/app/src/GraphQL/Codeunits/ShpfyGQLProductOptionUpdate.Codeunit.al deleted file mode 100644 index d45078353e..0000000000 --- a/Apps/W1/Shopify/app/src/GraphQL/Codeunits/ShpfyGQLProductOptionUpdate.Codeunit.al +++ /dev/null @@ -1,27 +0,0 @@ -namespace Microsoft.Integration.Shopify; - -/// -/// Codeunit Shpfy GQL ProductOptionUpdate (ID 30213) implements Interface Shpfy IGraphQL. -/// -codeunit 30213 "Shpfy GQL ProductOptionUpdate" implements "Shpfy IGraphQL" -{ - Access = Internal; - - /// - /// GetGraphQL. - /// - /// Return value of type Text. - internal procedure GetGraphQL(): Text - begin - exit('{"query": "mutation { productOptionUpdate(productId: \"gid://shopify/Product/{{ProductId}}\", option: {id: \"{{OptionId}}\", name: \"{{OptionName}}\"}) { product { id options { id name }} userErrors {field message}}}"}'); - end; - - /// - /// GetExpectedCost. - /// - /// Return value of type Integer. - internal procedure GetExpectedCost(): Integer - begin - exit(10); - end; -} diff --git a/Apps/W1/Shopify/app/src/GraphQL/Enums/ShpfyGraphQLType.Enum.al b/Apps/W1/Shopify/app/src/GraphQL/Enums/ShpfyGraphQLType.Enum.al index 4af6ee93e0..bed9e17242 100644 --- a/Apps/W1/Shopify/app/src/GraphQL/Enums/ShpfyGraphQLType.Enum.al +++ b/Apps/W1/Shopify/app/src/GraphQL/Enums/ShpfyGraphQLType.Enum.al @@ -410,9 +410,4 @@ enum 30111 "Shpfy GraphQL Type" implements "Shpfy IGraphQL" Caption = 'Get Product Options'; Implementation = "Shpfy IGraphQL" = "Shpfy GQL GetProductOptions"; } - value(80; ProductOptionUpdate) - { - Caption = 'Product Option Update'; - Implementation = "Shpfy IGraphQL" = "Shpfy GQL ProductOptionUpdate"; - } } diff --git a/Apps/W1/Shopify/app/src/Products/Codeunits/ShpfyCreateItemAsVariant.Codeunit.al b/Apps/W1/Shopify/app/src/Products/Codeunits/ShpfyCreateItemAsVariant.Codeunit.al index a9866d547c..15b97bf177 100644 --- a/Apps/W1/Shopify/app/src/Products/Codeunits/ShpfyCreateItemAsVariant.Codeunit.al +++ b/Apps/W1/Shopify/app/src/Products/Codeunits/ShpfyCreateItemAsVariant.Codeunit.al @@ -12,7 +12,6 @@ codeunit 30105 "Shpfy Create Item As Variant" CreateProduct: Codeunit "Shpfy Create Product"; VariantApi: Codeunit "Shpfy Variant API"; ProductApi: Codeunit "Shpfy Product API"; - RenameProductOption: Boolean; DefaultVariantId: BigInteger; trigger OnRun() @@ -30,8 +29,8 @@ codeunit 30105 "Shpfy Create Item As Variant" begin CreateProduct.CreateTempShopifyVariantFromItem(Item, TempShopifyVariant); TempShopifyVariant."Product Id" := ShopifyProduct."Id"; - TempShopifyVariant.Title := Item.Description; - TempShopifyVariant."Option 1 Name" := 'Item'; + TempShopifyVariant.Title := Item."No."; + TempShopifyVariant."Option 1 Name" := 'Variant'; TempShopifyVariant."Option 1 Value" := Item."No."; if VariantApi.AddProductVariant(TempShopifyVariant) then begin @@ -40,37 +39,52 @@ codeunit 30105 "Shpfy Create Item As Variant" end; end; + + /// + /// Checks if items can be added as variants to the product. The items cannot be added as variants if: + /// - The product has more than one option. + /// - The UoM as Variant setting is enabled. + /// + internal procedure CheckProductAndShopSettings() + var + 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'; + Options: Dictionary of [Text, Text]; + 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); + end; + /// - /// Checks if the product has only the default variant assigned and prepares the variant for deletion. + /// Finds the default variant ID for the product if the product has no variants. + /// If new variants will be added, the default variant will be removed. /// - internal procedure CheckIfProductHasDefaultVariant() + internal procedure FindDefaultVariantId() var ProductVariantIds: Dictionary of [BigInteger, DateTime]; begin if not ShopifyProduct."Has Variants" then begin - RenameProductOption := true; VariantApi.RetrieveShopifyProductVariantIds(ShopifyProduct, ProductVariantIds); DefaultVariantId := ProductVariantIds.Keys.Get(1); end; end; /// - /// Removes the default variant and renames the option if the product had only the default variant. + /// Removes the default variant if new variants were added to the product. /// - internal procedure RemoveDefaultVariantAndRenameOption() + internal procedure RemoveDefaultVariant() var ShopifyVariant: Record "Shpfy Variant"; - Options: Dictionary of [Text, Text]; begin - // If new variants were added to the product that only had the default variant, - // we need to remove the default variant from Shopify and BC and rename the option. - if RenameProductOption and ShopifyProduct."Has Variants" then begin + if (DefaultVariantId <> 0) and ShopifyProduct."Has Variants" then begin VariantApi.DeleteProductVariant(DefaultVariantId); if ShopifyVariant.Get(DefaultVariantId) then ShopifyVariant.Delete(true); - - Options := ProductApi.GetProductOptions(ShopifyProduct.Id); - ProductApi.UpdateProductOption(ShopifyProduct.Id, Options.Keys.Get(1), 'Item'); end; end; diff --git a/Apps/W1/Shopify/app/src/Products/Codeunits/ShpfyProductAPI.Codeunit.al b/Apps/W1/Shopify/app/src/Products/Codeunits/ShpfyProductAPI.Codeunit.al index c8ffcf7dc0..3878464a4b 100644 --- a/Apps/W1/Shopify/app/src/Products/Codeunits/ShpfyProductAPI.Codeunit.al +++ b/Apps/W1/Shopify/app/src/Products/Codeunits/ShpfyProductAPI.Codeunit.al @@ -628,21 +628,4 @@ codeunit 30176 "Shpfy Product API" foreach JOption in JOptions do Options.Add(JsonHelper.GetValueAsText(JOption, 'id'), JsonHelper.GetValueAsText(JOption, 'name')); end; - - /// - /// Updates the name of a Product Option. - /// - /// Shopify product ID for which the option is to be updated. - /// Option ID to be updated. - /// New name for the option. - internal procedure UpdateProductOption(ShopifyProductId: BigInteger; OptionId: Text; NewOptionName: Text) - var - Parameters: Dictionary of [Text, Text]; - begin - Parameters.Add('ProductId', Format(ShopifyProductId)); - Parameters.Add('OptionId', OptionId); - Parameters.Add('OptionName', NewOptionName); - - CommunicationMgt.ExecuteGraphQL(Enum::"Shpfy GraphQL Type"::ProductOptionUpdate, Parameters); - end; } \ No newline at end of file diff --git a/Apps/W1/Shopify/app/src/Products/Reports/ShpfyAddItemAsVariant.Report.al b/Apps/W1/Shopify/app/src/Products/Reports/ShpfyAddItemAsVariant.Report.al index 3d4731c3a9..b7774c6e54 100644 --- a/Apps/W1/Shopify/app/src/Products/Reports/ShpfyAddItemAsVariant.Report.al +++ b/Apps/W1/Shopify/app/src/Products/Reports/ShpfyAddItemAsVariant.Report.al @@ -24,7 +24,8 @@ report 30117 "Shpfy Add Item As Variant" Clear(CreateItemAsVariant); CreateItemAsVariant.SetParentProduct(ParentProductNo); - CreateItemAsVariant.CheckIfProductHasDefaultVariant(); + CreateItemAsVariant.CheckProductAndShopSettings(); + CreateItemAsVariant.FindDefaultVariantId(); if GuiAllowed then begin CurrItemNo := Item."No."; @@ -45,7 +46,7 @@ report 30117 "Shpfy Add Item As Variant" trigger OnPostDataItem() begin - CreateItemAsVariant.RemoveDefaultVariantAndRenameOption(); + CreateItemAsVariant.RemoveDefaultVariant(); if GuiAllowed then ProcessDialog.Close(); From 9e016f7c243a512bbfcac05c584e9d6097c74e42 Mon Sep 17 00:00:00 2001 From: Tine Staric Date: Thu, 20 Jun 2024 12:18:45 +0300 Subject: [PATCH 07/10] Fix ID Collision --- .../src/Products/Codeunits/ShpfyCreateItemAsVariant.Codeunit.al | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Apps/W1/Shopify/app/src/Products/Codeunits/ShpfyCreateItemAsVariant.Codeunit.al b/Apps/W1/Shopify/app/src/Products/Codeunits/ShpfyCreateItemAsVariant.Codeunit.al index 15b97bf177..a62d4c3830 100644 --- a/Apps/W1/Shopify/app/src/Products/Codeunits/ShpfyCreateItemAsVariant.Codeunit.al +++ b/Apps/W1/Shopify/app/src/Products/Codeunits/ShpfyCreateItemAsVariant.Codeunit.al @@ -2,7 +2,7 @@ namespace Microsoft.Integration.Shopify; using Microsoft.Inventory.Item; -codeunit 30105 "Shpfy Create Item As Variant" +codeunit 30213 "Shpfy Create Item As Variant" { TableNo = Item; From 5203347049b3f0e245cb4b6b433ba86b4a9d7d02 Mon Sep 17 00:00:00 2001 From: Tine Staric Date: Fri, 21 Jun 2024 16:56:50 +0300 Subject: [PATCH 08/10] Add missing access property --- .../src/Products/Codeunits/ShpfyCreateItemAsVariant.Codeunit.al | 1 + 1 file changed, 1 insertion(+) diff --git a/Apps/W1/Shopify/app/src/Products/Codeunits/ShpfyCreateItemAsVariant.Codeunit.al b/Apps/W1/Shopify/app/src/Products/Codeunits/ShpfyCreateItemAsVariant.Codeunit.al index a62d4c3830..2e95cd3a95 100644 --- a/Apps/W1/Shopify/app/src/Products/Codeunits/ShpfyCreateItemAsVariant.Codeunit.al +++ b/Apps/W1/Shopify/app/src/Products/Codeunits/ShpfyCreateItemAsVariant.Codeunit.al @@ -5,6 +5,7 @@ using Microsoft.Inventory.Item; codeunit 30213 "Shpfy Create Item As Variant" { TableNo = Item; + Access = Internal; var Shop: Record "Shpfy Shop"; From 356a6ce60bc4a1e573b20daf97d8689fe57c1f43 Mon Sep 17 00:00:00 2001 From: Tine Staric Date: Wed, 10 Jul 2024 10:59:45 +0300 Subject: [PATCH 09/10] Update Return value documentation --- .../app/src/Products/Codeunits/ShpfyCreateProduct.Codeunit.al | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Apps/W1/Shopify/app/src/Products/Codeunits/ShpfyCreateProduct.Codeunit.al b/Apps/W1/Shopify/app/src/Products/Codeunits/ShpfyCreateProduct.Codeunit.al index fc276ff98f..e81da72f87 100644 --- a/Apps/W1/Shopify/app/src/Products/Codeunits/ShpfyCreateProduct.Codeunit.al +++ b/Apps/W1/Shopify/app/src/Products/Codeunits/ShpfyCreateProduct.Codeunit.al @@ -174,7 +174,7 @@ codeunit 30174 "Shpfy Create Product" /// Parameter of type Code[20]. /// Parameter of type Code[10]. /// Parameter of type Code[10]. - /// Return value of type Text. + /// Return value of type Code[50]. local procedure GetVendorItemNo(ItemNo: Code[20]; VariantCode: Code[10]; UoM: Code[10]): Code[50]; var Item: Record Item; From 79c0d3b847654c7e9d15d6370151e555cb8b37c3 Mon Sep 17 00:00:00 2001 From: Tine Staric Date: Wed, 10 Jul 2024 12:34:49 +0300 Subject: [PATCH 10/10] Fix Object and Enum IDs --- .../GraphQL/Codeunits/ShpfyGQLGetProductOptions.Codeunit.al | 4 ++-- .../Codeunits/ShpfyGQLProductVariantDelete.Codeunit.al | 4 ++-- .../W1/Shopify/app/src/GraphQL/Enums/ShpfyGraphQLType.Enum.al | 4 ++-- .../Products/Codeunits/ShpfyCreateItemAsVariant.Codeunit.al | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Apps/W1/Shopify/app/src/GraphQL/Codeunits/ShpfyGQLGetProductOptions.Codeunit.al b/Apps/W1/Shopify/app/src/GraphQL/Codeunits/ShpfyGQLGetProductOptions.Codeunit.al index 85de24721b..46a753e828 100644 --- a/Apps/W1/Shopify/app/src/GraphQL/Codeunits/ShpfyGQLGetProductOptions.Codeunit.al +++ b/Apps/W1/Shopify/app/src/GraphQL/Codeunits/ShpfyGQLGetProductOptions.Codeunit.al @@ -1,9 +1,9 @@ namespace Microsoft.Integration.Shopify; /// -/// Codeunit Shpfy GQL GetProductOptions (ID 30168) implements Interface Shpfy IGraphQL. +/// Codeunit Shpfy GQL GetProductOptions (ID 30345) implements Interface Shpfy IGraphQL. /// -codeunit 30168 "Shpfy GQL GetProductOptions" implements "Shpfy IGraphQL" +codeunit 30345 "Shpfy GQL GetProductOptions" implements "Shpfy IGraphQL" { Access = Internal; diff --git a/Apps/W1/Shopify/app/src/GraphQL/Codeunits/ShpfyGQLProductVariantDelete.Codeunit.al b/Apps/W1/Shopify/app/src/GraphQL/Codeunits/ShpfyGQLProductVariantDelete.Codeunit.al index 7b387c817b..e362b36a96 100644 --- a/Apps/W1/Shopify/app/src/GraphQL/Codeunits/ShpfyGQLProductVariantDelete.Codeunit.al +++ b/Apps/W1/Shopify/app/src/GraphQL/Codeunits/ShpfyGQLProductVariantDelete.Codeunit.al @@ -1,9 +1,9 @@ namespace Microsoft.Integration.Shopify; /// -/// Codeunit Shpfy GQL ProductVariantDelete (ID 30159) implements Interface Shpfy IGraphQL. +/// Codeunit Shpfy GQL ProductVariantDelete (ID 30344) implements Interface Shpfy IGraphQL. /// -codeunit 30159 "Shpfy GQL ProductVariantDelete" implements "Shpfy IGraphQL" +codeunit 30344 "Shpfy GQL ProductVariantDelete" implements "Shpfy IGraphQL" { Access = Internal; diff --git a/Apps/W1/Shopify/app/src/GraphQL/Enums/ShpfyGraphQLType.Enum.al b/Apps/W1/Shopify/app/src/GraphQL/Enums/ShpfyGraphQLType.Enum.al index 9e7f36bc8c..5991ef71dd 100644 --- a/Apps/W1/Shopify/app/src/GraphQL/Enums/ShpfyGraphQLType.Enum.al +++ b/Apps/W1/Shopify/app/src/GraphQL/Enums/ShpfyGraphQLType.Enum.al @@ -405,12 +405,12 @@ enum 30111 "Shpfy GraphQL Type" implements "Shpfy IGraphQL" Caption = 'Get Order Transactions'; Implementation = "Shpfy IGraphQL" = "Shpfy GQL OrderTransactions"; } - value(79; ProductVariantDelete) + value(85; ProductVariantDelete) { Caption = 'Product Variant Delete'; Implementation = "Shpfy IGraphQL" = "Shpfy GQL ProductVariantDelete"; } - value(80; GetProductOptions) + value(86; GetProductOptions) { Caption = 'Get Product Options'; Implementation = "Shpfy IGraphQL" = "Shpfy GQL GetProductOptions"; diff --git a/Apps/W1/Shopify/app/src/Products/Codeunits/ShpfyCreateItemAsVariant.Codeunit.al b/Apps/W1/Shopify/app/src/Products/Codeunits/ShpfyCreateItemAsVariant.Codeunit.al index 2e95cd3a95..d323d2a4b5 100644 --- a/Apps/W1/Shopify/app/src/Products/Codeunits/ShpfyCreateItemAsVariant.Codeunit.al +++ b/Apps/W1/Shopify/app/src/Products/Codeunits/ShpfyCreateItemAsVariant.Codeunit.al @@ -2,7 +2,7 @@ namespace Microsoft.Integration.Shopify; using Microsoft.Inventory.Item; -codeunit 30213 "Shpfy Create Item As Variant" +codeunit 30343 "Shpfy Create Item As Variant" { TableNo = Item; Access = Internal;