fix(vtex): filter undefined products from sortProducts

GU
4mo ago
+1-1

Summary

  • When requesting products by SKU IDs via intelligentSearch/productList.ts, if a SKU doesn't exist or is inactive, the VTEX API omits it from the response
  • The sortProducts function maps over the original ID list, which resulted in undefined entries for missing SKUs
  • Added .filter(Boolean) to remove undefined entries from the returned array

Test plan

  • Configure a product shelf with SKU IDs where at least one is inactive/nonexistent
  • Verify the loader returns only valid products without undefined entries
  • Verify the remaining products maintain the original order

🤖 Generated with Claude Code


Summary by cubic

Fixes VTEX product sorting when requesting by SKU IDs by removing undefined entries for missing/inactive SKUs, preserving the order of valid products. Implemented by adding .filter(Boolean) to sortProducts in vtex/utils/transform.ts.

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Fixed product sorting to exclude missing or unavailable products from results. Undefined entries that appeared when requested products weren't found are now properly filtered out, providing cleaner and more reliable output.