Closed russback closed 11 months ago
You should be able to do:
{% set products = craft.shopifyProducts
.shopifyProductId(productIds)
.orderBy(create(
'craft\\db\\FixedOrderExpression',
['shopify_products.shopifyId', productIds, craft.app.db]
)).collect()
%}
If we get other people asking for this, I will look into it. Thanks!
Would also like this! Would be cool if we could drag the order with the 4 dots like entries in a structure?
@lukeholder just coming back to this as the project has been on hold.
With that query I'm getting this error:
Twig Runtime Error – [Twig\Error\RuntimeError](http://twig.sensiolabs.org/api/2.x/Twig/Error/RuntimeError.html)
Calling unknown method: craft\shopify\elements\db\ProductQuery::shopifyProductId()
Description
When passing an array of shopifyIds, the returned order does not match the order of the array of IDs passed. When adding
fixedOrder(true)
, no results are returned.This does not return products in the order the of the
productIds
array passed:{% set products = craft.shopifyProducts.shopifyId(productIds).collect %}
This returns no results:
{% set products = craft.shopifyProducts.shopifyId(productIds).fixedOrder(true).collect %}
Steps to reproduce
productIds
in an order that is different to the default order products are stored in Craft.Additional info