Skip to content

Bug Report: Product Translation Update Loses Original Item Reference #8296

Description

@ReneGubler

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é

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions