Comment on page
💪
Shop object
- Use
{{ shop }}
in any task, at any time
Use caution when loading large sets of resources through the shop object. Using code like
{% product in shop.products %}
will result in Mechanic downloading the complete REST representation of all products in the store, which may be more data than is necessary or useful. When working with large amounts of data, consider using GraphQL instead.
For clarity: looking up a single resource by ID will only result in a single REST API call, as in
{% assign product = shop.products[1234567890] %}
. If many of these requests are necessary, it may still be useful to look to GraphQL, but this kind of usage does not load more than the specific, single resource identified.{{ shop.collections[1234567890] }}
{% for collection in shop.collections %}
{{ shop.products[1234567890] }}
{% for product in shop.products %}
{% for product in shop.products.published %}
{{ shop.variants[1234567890] }}
{% for variant in shop.variants %}
{{ shop.orders[1234567890] }}
{% for order in shop.orders %}
{% for order in shop.orders.paid %}
{{ shop.draft_orders[1234567890] }}
{% for draft_order in shop.draft_orders.invoice_sent %}
{{ shop.customers[1234567890] }}
{{ shop.customers["[email protected]"] }}
{% for customer in shop.customers %}
{{ shop.price_rules[1234567890] }}
{% for price_rule in shop.price_rules %}
{{ shop.discount_codes["SUMMERTIME"] }}
{{ shop.blogs[1234567890] }}
{% for blog in shop.blogs %}
{{ shop.articles.tags }}
{{ shop.articles.authors }}
{% for shipping_zone in shop.shipping_zones %}
{{ shop.metafields }}
Last modified 2yr ago