How to Extract Specific Product Details From the Shopify Product Description Using EZ Exporter

As a Shopify merchant, you probably already know that when you perform a CSV export of your products via the Shopify Admin, the product description will include all the HTML tags in the data. Our EZ Exporter app can easily strip these out.

However, there may be more complex cases where you need to go even a step further, where you need to extract specific product attributes that were entered directly in the HTML product description in Shopify. You might have placed these additional details in the product description directly because you simply didn't know where else to put them.

Each product variant, for instance, can only have a maximum of 3 options and there are no built-in fields for attributes such as the item's condition. You can add additional product attributes using Metafields, but it requires a third-party app to add them.

You might also have imported the product data from somewhere else which put all the product attributes directly in the HTML description.

This can be a problem if you then have to generate a product feed from this data to use in other platforms that needs certain specific product details in separate columns in a CSV file.

If there's a consistent structure in the HTML description where the information you need is labeled, EZ Exporter might be able to extract them and place them in separate columns in the CSV export.

For example, your product description might look something like this:

Shopify product description with additional product attributes

As you can see above, there's a section that lists the additional product attributes such as the "Weight" and "Condition" in a consistent "Attribute Name: Value" format where each attribute is a separate line.

If you export this product description to CSV, you'll get the HTML code that looks something like this:

<p>Meow. This cat is a pain in the behind, you can have it, pay only shipping.</p>
<p><strong>Weight: </strong>45lbs<br><strong>Condition:</strong> Healthy<br><strong>Favorite Activity: </strong>Eat and siesta<br></p>
<p>Gets along well with dogs, a bit picky with food.<br></p>

EZ Exporter can parse this information and pull those labeled product attributes using a formula like this in the Calculated Fields:

search_list(strip_html_tags({{ body_html }}.replace("<br>", "\n")).split("\n"), "Condition:", return_all_results=False).replace("Condition:", "").strip()

The formula above will pull the value after "Condition: " and place it on a separate field. As you can tell, this is a very complex formula that combines multiple functions just to retrieve that data.

This is basically what the formula is doing:

  1. Replace the "<br>" tag in the HTML to a normal "newline" character (essentially a line break).
  2. Strip out all the HTML tags from the data so we're left with just the regular text description.
  3. Split up the description data where each line in the description is added to a list/array of elements.
  4. Search this array/list for an element that contains the text "Condition:" and pull out that element.
  5. Remove the text "Condition:" from that element and strip out all leading and trailing spaces, what's left would then just be the value of that element (i.e. the word "Healthy" in this case, which then gets placed in a custom column in the CSV export).

That's quite a lot of steps just to pull out that data!

TLDR: The main thing to note here is the part where it says "Condition:". You can basically just copy and paste this formula into additional Calculated Fields and replace that part with the name of the attribute you'd like to extract.

Here's an example of formulas that extract the Weight, Condition, and Favorite Activity attributes:

EZ Exporter - Extract product attributes from Shopify product description

And the output will look something like this:

EZ Exporter - Extract product attributes from Shopify HTML descriptions to CSV

Please note that our app can only extract these product attributes from the product descriptions if there's a consistent structure of one attribute per line and where each attribute is labeled.

Tags: shopify, ez exporter, howto, product feed