Mechanic is a development and ecommerce automation platform for Shopify. :)
Running manually or on a schedule, this task scans all products in your store, and adds a tag to any products that have no images. Optionally, choose to have this task remove that tag from any products that are found to have an image.
Runs Occurs when a user manually triggers the task and Occurs when a bulk operation is completed. Configuration includes product tag to add, remove product tag if images are found, run every 10 minutes, run hourly, and run daily.
Mechanic is designed to benefit everybody: merchants, customers, developers, agencies, Shopifolks, 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.
(By the way, have you seen our documentation? Have you joined the Slack community?)
mechanic/user/trigger {% if options.run_every_10_minutes__boolean %} mechanic/scheduler/10min {% elsif options.run_hourly__boolean %} mechanic/scheduler/hourly {% elsif options.run_daily__boolean %} mechanic/scheduler/daily {% endif %} mechanic/shopify/bulk_operation
{% if event.topic == "mechanic/user/trigger" or event.topic contains "mechanic/scheduler/" %} {% capture bulk_operation_query %} query { products { edges { node { __typename id tags images { edges { node { __typename id } } } } } } } {% endcapture %} {% action "shopify" %} mutation { bulkOperationRunQuery( query: {{ bulk_operation_query | json }} ) { bulkOperation { id status } userErrors { field message } } } {% endaction %} {% elsif event.topic == "mechanic/shopify/bulk_operation" %} {% if event.preview %} {% capture bulkOperation_objects_jsonl %} {"__typename":"Product","id":"gid:\/\/shopify\/Product\/1234567890","tags":[]} {% endcapture %} {% assign bulkOperation = hash %} {% assign bulkOperation["objects"] = bulkOperation_objects_jsonl | parse_jsonl %} {% endif %} {% assign products = bulkOperation.objects | where: "__typename", "Product" %} {% assign images = bulkOperation.objects | where: "__typename", "Image" %} {% for product in products %} {% assign product_images = images | where: "__parentId", product.id %} {% if product_images.size == 0 %} {% unless product.tags contains options.product_tag_to_add__required %} {% action "shopify" %} mutation { tagsAdd( id: {{ product.id | json }} tags: {{ options.product_tag_to_add__required | json }} ) { userErrors { field message } } } {% endaction %} {% endunless %} {% else %} {% if product.tags contains options.product_tag_to_add__required and options.remove_product_tag_if_images_are_found__boolean %} {% action "shopify" %} mutation { tagsRemove( id: {{ product.id | json }} tags: {{ options.product_tag_to_add__required | json }} ) { userErrors { field message } } } {% endaction %} {% endif %} {% endif %} {% endfor %} {% endif %}