Mechanic is a development and ecommerce automation platform for Shopify. :)
Use this task to quickly (and permanently) clear out your product list. Optionally, filter by a specific query, so as to only delete specific products from your store. Supports a test mode, allowing you to see exactly what products you can expect Mechanic to delete.
Runs Occurs when a user manually triggers the task. Configuration includes query, test mode, and live mode.
Use this task to quickly (and permanently) clear out your product list. Optionally, filter by a specific query, so as to only delete specific products from your store. Supports a test mode, allowing you to see exactly what products you can expect Mechanic to delete.
Use this task to quickly clear out your product list.
Caution: if you leave the query option empty, this task will delete every product in your store.
Use the "query" setting to get specific about what products you want to delete. Tick the "Test mode" checkbox to verify which products will be deleted: after saving, use the "Run task" button to run the product scan, and you'll receive a list of products that Mechanic would have deleted in live mode. Once you're ready, uncheck the "Test mode" box and check the "Live mode" box, save the task, then use "Run task" to permanently delete all matching products.
Example queries:
product_type:Shirt
tag:old
Learn more:
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
{% assign product_ids_and_titles = hash %} {% assign cursor = nil %} {% for n in (0..100) %} {% capture query %} query { products( first: 250 after: {{ cursor | json }} sortKey: TITLE query: {{ options.query | json }} ) { pageInfo { hasNextPage } edges { cursor node { id title } } } } {% endcapture %} {% assign result = query | shopify %} {% if event.preview %} {% capture result_json %} { "data": { "products": { "pageInfo": { "hasNextPage": false }, "edges": [ { "node": { "id": "gid://shopify/Product/1234567890", "title": "[sample product]" } } ] } } } {% endcapture %} {% assign result = result_json | parse_json %} {% endif %} {% for product_edge in result.data.products.edges %} {% assign product_ids_and_titles[product_edge.node.id] = product_edge.node.title %} {% endfor %} {% if result.data.products.pageInfo.hasNextPage %} {% assign cursor = result.data.products.edges.last.cursor %} {% else %} {% break %} {% endif %} {% endfor %} {% if options.test_mode__boolean and options.live_mode__boolean %} {% error "Please choose either test mode or live mode." %} {% elsif options.test_mode__boolean == false and options.live_mode__boolean == false %} {% error "Please choose either test mode or live mode." %} {% elsif options.test_mode__boolean %} {% log products_found_count: product_ids_and_titles.size, products_found: product_ids_and_titles %} {% elsif options.live_mode__boolean %} {% for keyval in product_ids_and_titles %} {% action "shopify" %} mutation { productDelete( input: { id: {{ keyval[0] | json }} } ) { deletedProductId userErrors { field message } } } {% endaction %} {% endfor %} {% endif %}
true