Skip to content

Commit

Permalink
third batch of REST to GraphQL conversions for products and variants
Browse files Browse the repository at this point in the history
  • Loading branch information
tekhaus committed Oct 8, 2024
1 parent 94293db commit 762702b
Show file tree
Hide file tree
Showing 13 changed files with 460 additions and 180 deletions.
8 changes: 4 additions & 4 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ This directory is built automatically. Each task's documentation is generated fr
* [Auto-remove a product tag x days after it's added](./auto-remove-a-product-tag-x-days-after-its-added)
* [Auto-remove attributes on new orders after X minutes](./auto-remove-attributes-on-new-orders-after-x-minutes)
* [Auto-reserve draft order items for X days](./auto-reserve-draft-order-items-for-x-days)
* [Auto-sort collections by a product property](./auto-sort-collections-by-product-properties)
* [Auto-sort collections by inventory levels](./auto-sort-collections-by-inventory-levels)
* [Auto-sort collections by product properties](./auto-sort-collections-by-product-properties)
* [Auto-tag a customer's first order](./auto-tag-a-customers-first-order)
* [Auto-tag cancelled orders](./auto-tag-cancelled-orders)
* [Auto-tag customers based on discount codes used](./auto-tag-customers-based-on-discount-codes-used)
Expand Down Expand Up @@ -622,8 +622,8 @@ This directory is built automatically. Each task's documentation is generated fr
* [Auto create collections by metafield values](./auto-create-collections-by-metafield-values)
* [Auto-add products to a custom collection when tagged](./auto-add-products-to-a-custom-collection-when-tagged)
* [Auto-create collections by product type or vendor](./auto-create-collections-by-product-type-or-vendor)
* [Auto-sort collections by a product property](./auto-sort-collections-by-product-properties)
* [Auto-sort collections by inventory levels](./auto-sort-collections-by-inventory-levels)
* [Auto-sort collections by product properties](./auto-sort-collections-by-product-properties)
* [Auto-tag orders by product collections](./auto-tag-orders-by-product-collections)
* [Auto-tag products in a manual collection](./auto-tag-products-in-a-manual-collection)
* [Delete the oldest x products from a specific collection](./delete-the-oldest-x-products-from-a-specific-collection)
Expand Down Expand Up @@ -1353,7 +1353,7 @@ This directory is built automatically. Each task's documentation is generated fr
* [Auto-publish new products](./auto-publish-new-products)
* [Auto-publish products tagged with the current day](./auto-publish-products-tagged-with-the-current-day)
* [Auto-reserve draft order items for X days](./auto-reserve-draft-order-items-for-x-days)
* [Auto-sort collections by product properties](./auto-sort-collections-by-product-properties)
* [Auto-sort collections by a product property](./auto-sort-collections-by-product-properties)
* [Auto-tag customers when they purchase a matching product](./auto-tag-customers-upon-product-purchase)
* [Auto-tag customers who purchase an item on sale](./auto-tag-customers-who-purchase-an-item-on-sale)
* [Auto-tag customers with product tags from their order](./tag-customers-with-product-tags-from-their-order)
Expand Down Expand Up @@ -1641,8 +1641,8 @@ This directory is built automatically. Each task's documentation is generated fr

### Sort

* [Auto-sort collections by a product property](./auto-sort-collections-by-product-properties)
* [Auto-sort collections by inventory levels](./auto-sort-collections-by-inventory-levels)
* [Auto-sort collections by product properties](./auto-sort-collections-by-product-properties)
* [Move out-of-stock products to the end of a collection](./move-out-of-stock-products-to-the-end-of-a-collection)

### Spend
Expand Down
2 changes: 1 addition & 1 deletion docs/auto-fulfill-orders-when-tagged/script.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
{% for keyval in fulfillment_order_ids_by_location_and_type %}
{% action "shopify" %}
mutation {
fulfillmentCreateV2(
fulfillmentCreate(
fulfillment: {
lineItemsByFulfillmentOrder: [
{% for fulfillment_order_id in keyval[1] %}
Expand Down
22 changes: 13 additions & 9 deletions docs/auto-sort-collections-by-product-properties/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Auto-sort collections by product properties
# Auto-sort collections by a product property

Tags: Collections, Products, Sort

This task re-sorts your collections by any product property that you choose. Use the "Product property lookups" option to control what attribute the task "looks up". For example, using "published_at" will result in sorting by the date and time the product was published. Add more than one lookup to dive more deeply into product data: using the lookups "metafields", "store", "priority", and "value" will result in a collection sorted by the `store.priority` metafield value on each product.
This task re-sorts your collections by the product property, product metafield, or variant property that you choose. Use the "Product property" or "First variant property" options to control what attribute the task looks up. For example, using `publishedAt` in the "Product property" field will result in sorting by the date and time the product was published, while using `sku` in the "First variant property" field will result in sorting by the sku of the first variant of each product in the collection. Alternatively, enter a product metafield as "namespace.key" (e.g. `store.priority`), and the task will attempt to sort by the value of that metafield.

* View in the task library: [tasks.mechanic.dev/auto-sort-collections-by-product-properties](https://tasks.mechanic.dev/auto-sort-collections-by-product-properties)
* Task JSON, for direct import: [task.json](../../tasks/auto-sort-collections-by-product-properties.json)
Expand All @@ -12,9 +12,9 @@ This task re-sorts your collections by any product property that you choose. Use

```json
{
"product_property_lookups__array_required": [
"published_at"
],
"product_property": "publishedAt",
"product_metafield": "",
"first_variant_property": "",
"only_sort_these_collections__array": null,
"reverse_sort__boolean": false,
"run_hourly__boolean": false,
Expand All @@ -41,13 +41,17 @@ user/collection_sort/complete

## Documentation

This task re-sorts your collections by any product property that you choose. Use the "Product property lookups" option to control what attribute the task "looks up". For example, using "published_at" will result in sorting by the date and time the product was published. Add more than one lookup to dive more deeply into product data: using the lookups "metafields", "store", "priority", and "value" will result in a collection sorted by the `store.priority` metafield value on each product.
This task re-sorts your collections by the product property, product metafield, or variant property that you choose. Use the "Product property" or "First variant property" options to control what attribute the task looks up. For example, using `publishedAt` in the "Product property" field will result in sorting by the date and time the product was published, while using `sku` in the "First variant property" field will result in sorting by the sku of the first variant of each product in the collection. Alternatively, enter a product metafield as "namespace.key" (e.g. `store.priority`), and the task will attempt to sort by the value of that metafield.

Refer to [Shopify's API documentation](https://help.shopify.com/en/api/reference/products/product) to find the product property you're looking for.
Run this task manually to re-sort your collections on demand, or choose to run it hourly or nightly. This task will scan all collections in the shop on each run, unless you configure it to only sort certain collections using each collection's title, handle, or ID. Optionally, choose the "Reverse sort" option to have the results reversed, mainly useful for sorting by descending numeric values (e.g. `inventoryTotal`).

Run this task manually to re-sort your collections on demand, or choose to run it hourly or nightly.
**Important:**

This task will scan all collections in the shop on each run, unless you configure it to only sort certain collections using each collection's title or ID. The collections processed by this task must be configured for manual sorting, otherwise they will be ignored. [Learn how to change the sort order of your collections.](https://help.shopify.com/en/manual/products/collections/collection-layout#change-the-sort-order-for-the-products-in-a-collection)
- You may only choose one sorting method.
- The collections processed by this task must be configured for manual sorting, otherwise they will be ignored.
- The property you choose should be a `DateTime`, `Int`, or `String` field on the [GraphQL Product](https://shopify.dev/docs/api/admin-graphql/latest/objects/Product) or [GraphQL ProductVariant](https://shopify.dev/docs/api/admin-graphql/latest/objects/ProductVariant) resource, otherwise the task will generate an error during execution. For help migrating from prior versions of this task, Shopify has documented the mappings for [REST product properties](https://shopify.dev/docs/api/admin-rest/latest/resources/product) and [REST product variant properties](https://shopify.dev/docs/api/admin-rest/latest/resources/product-variant) to GraphQL. (e.g. REST: `published_at` => GraphQL: `publishedAt`)
- Products with values for a property/metafield will always be placed before products with no values. This rule applies even when the sort order is reversed.
- If a metafield is configured that does not exist, the task will just report that no moves are needed. No error will be thrown.

## Installing this task

Expand Down
Loading

0 comments on commit 762702b

Please sign in to comment.