You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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 #}
{% setids= [123, 456] %}
{% setproducts=craft.shopifyProducts.id(ids).fixedOrder().all() %}
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
The text was updated successfully, but these errors were encountered: