PhoenixKitEcommerce.Shopify.ProductDiff (PhoenixKitEcommerce v0.3.0)

Copy Markdown View Source

Compares local products against Shopify Admin API product data.

Matching is by product.slug[base_locale] == shopify_product["handle"]. A Shopify product with no local match is skipped — this module never creates products, only flags differences on ones that already exist (product creation stays the CSV importer's job).

Compared fields: title, body_html, description, vendor, tags, status, price. title/body_html/description are localized fields; only the base locale is read/compared here (writing them back is Shopify.Sync.apply_change/2's job).

diff/3 is pure — no network or database access — so it can be tested directly with in-memory product structs and Shopify API response maps.

Summary

Functions

Matches shopify_products to local_products by handle and returns one Change per match that has at least one real difference. Shopify products without a matching local product are skipped.

Functions

diff(local_products, shopify_products, base_locale \\ Translations.default_language())

Matches shopify_products to local_products by handle and returns one Change per match that has at least one real difference. Shopify products without a matching local product are skipped.

base_locale defaults to Translations.default_language/0, which reads through PhoenixKit.Settings — pass it explicitly to keep a call free of database access (e.g. in tests).