All things Shopify and commerce
I am trying to create a section on the home page to show newest products published using the following code, however I am not getting accurate data:
assign all_products = collections.all.products | sort: 'published_at' | reverse
It's just not giving me the latest products compared to when I go to the All Collection sort by Date New to Old
Here is how I am rendering the products:
{% liquid for product in all_products limit: section.settings.limit render 'product-item', product: product endfor %}
What could be the issue?
Solved! Go to the solution
This is an accepted solution.
Hello @Aidin3000
replace your code with this code
and check it
{% assign newest_products = collections['newest-products'].products | sort: 'published_at' | reverse %}
{% for product in newest_products limit: section.settings.limit %}
{% render 'product-item', product: product %}
{% endfor %}
This is an accepted solution.
Hello @Aidin3000
replace your code with this code
and check it
{% assign newest_products = collections['newest-products'].products | sort: 'published_at' | reverse %}
{% for product in newest_products limit: section.settings.limit %}
{% render 'product-item', product: product %}
{% endfor %}
This worked but I had to create a collection called Newest Products that listed all products for it to work.
Any reason this didnt work with the All collection?
Thank you.
ok thanxx let me try it
if you think i was helpful could you buy me a coffee ??
By 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, 2024Thanks to everyone who participated in our AMA with 2H Media: Marketing Your Shopify St...
By Jacqui Sep 6, 2024