How can I export all barcodes by type from my Shopify product data?

The variants.barcodes field in the Shopify API returns the data as a JSON array of attributes like this:

[
    {
        "type": null,
        "value": "0123318"
    },
    {
        "type": "GTIN",
        "value": "00012345678905"
    },
    {
        "type": "GTIN",
        "value": "012345678905"
    },
    {
        "type": "UPC",
        "value": "036000291452"
    },
    {
        "type": "EAN",
        "value": "4006381333931"
    },
    {
        "type": "ISBN",
        "value": "9780201379624"
    },
    {
        "type": "ASIN",
        "value": "ABC123DEF4"
    },
    {
        "type": "NS_PID",
        "value": "PART-12345"
    }
]

You can use the following formulas in the Calculated Fields to export the different types of barcodes associated with each Shopify product variant in separate columns:

Custom Barcodes

search_attributes({{ variants.barcodes }}, None, search_key="type", result_key="value", return_all_results=True)

GTIN (Global Trade Item Number)

search_attributes({{ variants.barcodes }}, "GTIN", search_key="type", result_key="value", return_all_results=True)

UPC (Universal Product Code)

search_attributes({{ variants.barcodes }}, "UPC", search_key="type", result_key="value", return_all_results=True)

EAN (European Article Number)

search_attributes({{ variants.barcodes }}, "EAN", search_key="type", result_key="value", return_all_results=True)

ISBN (International Standard Book Number)

search_attributes({{ variants.barcodes }}, "ISBN", search_key="type", result_key="value", return_all_results=True)

ASIN (Amazon Standard Identification Number)

search_attributes({{ variants.barcodes }}, "ASIN", search_key="type", result_key="value", return_all_results=True)

NS_PID (Non-Standardized Manufacturer Product Identifier)

search_attributes({{ variants.barcodes }}, "NS_PID", search_key="type", result_key="value", return_all_results=True)

Sample output

Note that Shopify allows entering multiple barcodes of the same type.  In this case, the formulas will export all of them separated by a comma.

On the app's "Templates" page, there's also a template you can use called "Variant Barcodes" which already has the above formulas configured and can be customized further.


App: EZ Exporter

Tags: barcodes, shopify product export