Posted on 20/03/2019 19:57:39
Hey
We have a problem with duplicate units, and found this SQL query from the debug tool, it looks like when joining on EcomVariantGroups. The
LanguageId is missing in the where clause. (EcomVariantGroups.VariantGroupLanguageId = @p0) results in duplicate units in the output.
DECLARE
@p0 NVARCHAR(5) = N'LANG1',
@p1 NVARCHAR(6) = N'275020',
@p2 NVARCHAR(4000) = N'',
@p3 NVARCHAR(1) = N'1'
SELECT EcomVariantsOptions.*
FROM EcomVariantsOptions
INNER JOIN EcomVariantGroups ON EcomVariantGroups.VariantGroupID = EcomVariantsOptions.VariantOptionGroupID
INNER JOIN EcomStockUnit ON EcomStockUnit.StockUnitID=EcomVariantsOptions.VariantOptionId
WHERE
EcomVariantsOptions.VariantOptionLanguageID = @p0
AND
EcomStockUnit.StockUnitProductID = @p1
AND
StockUnitVariantID = @p2
AND
EcomVariantGroups.VariantGroupUnit = @p3
ORDER BY VariantOptionSortOrder, VariantOptionId