Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
So, I'm trying to get products json within my custom template search.data.liquid:
... {%- for product in search.results -%} ... {{ product | json }} ...
And I discovered, that variants in products json are ordered differently, than they are ordered in admin dashboard. (For example, in dashboard 'basic' comes first, followed by 'custom' & 'deluxe', and I get ['custom', 'deluxe', 'basic'] in json)
I tried to rearrange them, but that doesn't help.
Sort order is very important in my case. Is there a way to get variants array in correct order?
In Shopify, the order of variants in the JSON representation of a product is based on the order in which they were created, not their display order in the admin dashboard. If you need to have the variants in a specific order, you can update the variants' positions in the admin dashboard to reflect the desired order.
Here's how you can update the variant order in the admin dashboard:
Go to your Shopify admin dashboard and navigate to the product that contains the variants you want to reorder.
Scroll down to the "Variants" section of the product editing page.
Click on the "Edit variants" button.
You will see a list of variants for the product. You can click and drag each variant to rearrange their order.
Drag the variants into the desired order, placing them according to your preference.
Click the "Save" button to apply the changes.
Once you have updated the variant order in the admin dashboard, the JSON representation of the product's variants should reflect the new order.
My problem is that once I have updated the variant order in the admin dashboard, the JSON representation of the product's variants does not reflect the new order, as I've explained in the opening post.
Hey Jacob,
We've just found our website is suffering the same issue. Did you ever find a resolution?
Thanks
Adam
Starting a B2B store is a big undertaking that requires careful planning and execution. W...
By JasonH Sep 23, 2024By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024