AL icon indicating copy to clipboard operation
AL copied to clipboard

Bug Report: Product Translation Update Loses Original Item Reference

Open ReneGubler opened this issue 4 months ago • 2 comments

Hi Team,

I've encountered an issue with the Shopify Connector in BC where product translations are not being updated correctly. The problem appears to be in the UpdateProductData procedure within Codeunit 30178 "Shpfy Product Export".

The Issue:

In the UpdateProductTranslations function call at the end of the procedure, the original item reference is being lost. The Item record variable has been overwritten by the last item variant processed in the loop, causing the translations to be applied to the wrong item.

Where it happens:

if ShopifyProduct.Get(ProductId) and Item.GetBySystemId(ShopifyProduct."Item SystemId") then begin // ... processing code ...

// Here the original Item gets overwritten in the variant loop:
if ShopifyVariant.FindSet(false) then
    repeat
        if not IsNullGuid(ShopifyVariant."Item SystemId") then
            if Item.GetBySystemId(ShopifyVariant."Item Variant SystemId") then begin  // <-- ITEM IS OVERWRITTEN HERE
                // ...
            end;
    until ShopifyVariant.Next() = 0;

// The last Item reference is now from the last variant, not the original product
UpdateProductTranslations(ShopifyProduct.Id, Item)  // <-- INCORRECT ITEM PASSED

end;

Root Cause: The Item variable is reused throughout the procedure and gets overwritten when processing item variants. By the time we reach the UpdateProductTranslations call, Item no longer references the original product item but instead references the last variant's item.

Proposed Solution: Declare a separate variable for the original item that persists throughout the procedure

Use this original item variable for the UpdateProductTranslations call

Example: var OriginalItem: Record Item; // <-- Add this // ... other variables ... begin if ShopifyProduct.Get(ProductId) and OriginalItem.GetBySystemId(ShopifyProduct."Item SystemId") then begin // Use OriginalItem throughout, and a separate Item variable for variant processing UpdateProductTranslations(ShopifyProduct.Id, OriginalItem) // <-- Use OriginalItem here end; end;

Thank you, René

ReneGubler avatar Jul 20 '26 08:07 ReneGubler

This is the repository for the AL Language.

Your issue is about the application code. If you intend to fix it then I suggest to create an issue at https://github.com/microsoft/bcapps with the correct issue template.

If you only want to report it then use viva engage.

And if you report this since a customer is impacted then create a suppor request via the known process.

pri-kise avatar Jul 27 '26 11:07 pri-kise

This repository does not handle application requests and enhancements. Instead please use the following repository: https://github.com/microsoft/bcapps

PooyaKharamesh avatar Aug 10 '26 14:08 PooyaKharamesh