Closed AmandaLutzTO closed 7 months ago
Hi @AmandaLutzTO
This is possible to do, but when using the fixedOrder
param you must use the id()
criteria to be able to set the order. This id
is the element id in Craft.
As you identified you can retrieve the products from the Shopify collection and then query for them using the shopifyId
to get the corresponding Craft element ID. Once you have built this array of IDs you can then pass them into the Shopify products query as follows:
{# Where `ids` is a pre-built array of element IDs #}
{% set ids = [123, 456] %}
{% set products = craft.shopifyProducts.id(ids).fixedOrder().all() %}
Hope this helps, thanks!
Exactly what I was missing. Thanks.
Description
I've successfully used craft.shopify.api.get to get all of the products belonging to a Shopify Collection (https://shopify.dev/docs/api/admin-rest/2023-10/resources/collection#get-collections-collection-id-products). In the Shopify admin, the Collections have the products in order of "Best selling".
I can loop through all the products returned by the api to build an array of ids but I want them displayed in that order, not the current postDate DESC.
I've tried fixedOrder (https://craftcms.com/docs/4.x/entries.html#fixedorder) but returns an empty result set.
Steps to reproduce
Additional info