Create a product inventory feed with Mechanic.

Mechanic is the one-tool-does-it-all automation app for Shopify. :)

Create a product inventory feed

by Isaac Bowen (team@usemechanic.com)

This task, paired with the linked instructions, creates a feed of product inventory (optionally filtering by product type).

Runs when a user triggers the task, every day at midnight, and 12 hours after every day at midnight. Configuration includes filter by product type.

15-day free trial – unlimited tasks

Documentation

This task creates a regularly-updated feed, available at yourshop.com/pages/feed. Follow these required instructions to configure your shop:

Tutorial: Creating scheduled feeds with Mechanic

Developer details

Mechanic is designed to benefit everybody: merchants, customers, developers, agencies, Gurus, everybody.

That’s why we make it easy to configure automation without code, why we make it easy to tweak the underlying code once tasks are installed, and why we publish it all here for everyone to learn from.

Events
when a user triggers the task (mechanic/user/trigger)
every day at midnight (mechanic/scheduler/daily)
12 hours after every day at midnight (mechanic/scheduler/daily+12.hours)
Options
filter by product type
Script
{% capture newline %}
{% endcapture %}

{% assign csv = "Handle,Title,Option1 Name,Option1 Value,Option2 Name,Option2 Value,Option3 Name,Option3 Value,SKU,Quantity" %}

{% for product in shop.products %}
  {% if options.filter_by_product_type == blank or product.product_type == options.filter_by_product_type %}
    {% for variant in product.variants %}
      {% assign csv = csv | append: newline | append: product.handle %}
      {% assign csv = csv | append: "," | append: product.title %}
      {% assign csv = csv | append: "," | append: product.options[0].name %}
      {% assign csv = csv | append: "," | append: variant.option1 %}
      {% assign csv = csv | append: "," | append: product.options[1].name %}
      {% assign csv = csv | append: "," | append: variant.option2 %}
      {% assign csv = csv | append: "," | append: product.options[2].name %}
      {% assign csv = csv | append: "," | append: variant.option3 %}
      {% assign csv = csv | append: "," | append: variant.sku %}

      {% assign available = 0 %}
      {% for inventory_level in variant.inventory_levels %}
        {% assign available = available | plus: inventory_level.available %}
      {% endfor %}

      {% assign csv = csv | append: "," | append: available %}
    {% endfor %}
  {% endif %}
{% endfor %}

{
  "action": {
    "type": "shopify",
    "options": [
      "create",
      "metafield",
      {
        "namespace": "mechanic",
        "key": "feed",
        "value_type": "string",
        "value": {{ csv | json }}
      }
    ]
  }
}
Mechanic tasks are written in Liquid, which makes them easy to write and easy to modify. Learn more about our platform.
Defaults
Filter by product type
Shirt