Fix composition lookup by external product ID
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 2m1s

This commit is contained in:
Cauê Faleiros
2026-08-28 08:22:58 -03:00
parent 5e742feb60
commit bc6d53b840
2 changed files with 35 additions and 2 deletions

View File

@@ -1195,7 +1195,9 @@ const isSellableComposition = (order) => {
};
const getTinyProductIdFromCompositionReference = (tinyId) => (
tinyId.slice(TINY_OLIST_V3_COMPOSITION_PREFIX.length)
tinyId.startsWith(TINY_OLIST_V3_COMPOSITION_PREFIX)
? tinyId.slice(TINY_OLIST_V3_COMPOSITION_PREFIX.length)
: tinyId
);
const normalizeCompositionComponents = (components) => {
@@ -1291,6 +1293,7 @@ const findProductCompositionsBySource = async (source, productId, client = pool)
AND (
$2 = ''
OR composition.finished_tiny_product_id = $2
OR composition.external_source_id = $2
OR composition.finished_product_sku = UPPER($2)
)
ORDER BY composition.finished_product_sku, composition.finished_product_description;