Using a Formula for Mapping Product Variants to Shopify

There may be cases where the item ID (such as the SKU or Barcode) from your supplier's feed may differ slightly from the item ID in your store.

For example, your supplier's inventory feed might use all lowercase letters for the SKU and you use all uppercase in your Shopify store.  You might also have multiple suppliers carrying the same SKU, so you might add prefixes/suffixes to your SKUs in Shopify to identify which supplier/vendor they're related to.

EZ Inventory provides an option to use a formula against your inventory feed for these cases.  Since you likely don't have the ability to modify or customize your supplier's feed, this option allows you to add data manipulation and conditional logic when doing a lookup against your Shopify store's product variants database as the feed is processed.


Below are some sample formulas for different use cases where this feature would be useful.

1. Convert the value of the "sku" field in the inventory feed to all uppercase letters.

{{ sku }}.upper()

To convert to all lowercase instead:

{{ sku }}.lower()

2. Convert the value of the "sku" field in the inventory feed to all uppercase and then append the text "-VENDOR1" to it.

{{ sku }}.upper() + "-VENDOR1"

3. Append "-VENDOR1" only to specific SKUs, use the original value for the rest of them.

{{ sku }} + "-VENDOR1" if {{ sku }} in ["DHS1231", "3EA1441", "R2D2113"] else {{ sku }}

4. Remove all spaces from the "item_id" field of the inventory feed.

{{ item_id }}.replace(" ", "")

5. Replace the "-" character from the "item_id" field with the "X" character.

{{ item_id }}.replace("-", "X")

6. Remove all leading and trailing zeros from the value of the "item_id" field.

{{ item_id }}.strip("0")

To remove only the leading zeros:

{{ item_id }}.lstrip("0")

To remove only the trailing zeros:

{{ item_id }}.rstrip("0")

7. Replace the values in the "item_id" field with new values (similar to a lookup table). If there's no match from the key/value lookup, use the original value.

{"DA3821": "NEW-555112", "XHD1381": "NEW-381231", "YWF8124": "NEW-43818"}.get({{ item_id }}, {{ item_id }})

Related Articles:

App: EZ Inventory

Tags: advanced features, inventory management, supplier feed, product mapping