Display 12 Recently Added Products on Homepage

Highlighted
New Member
1 0 0

Hello everyone,

I have spent the last two days reading through forums and banging my head against a wall of sadness. I am currently using the Responsive Theme (NY Style) and am interested in displaying a collection on our homepage that shows our most recently added products.

I've already created a collection that automatically adds pieces to the collection based on price (anything that's more than $0.00) and it is displayed in order of newest to oldest. I named this collection "Newest Artwork". My problem is that I can't specify the number of displayed products to only 12 at a time.

I do not want to limit all collections to only show twelve products at a time, just this particular collection whether it's on the homepage or its own collection page. I realize this question has been asked quite a few times in the forums but I have yet to see a conclusive and/or current answer.

Any help on this matter is much appreciated, I know it takes a lot of time to go through these issues. Please let me know if there is anything I can clarify.
Kindly,
Laura

0 Likes
New Member
4 0 0

Hi Laura,

I just came across your post. Not sure if you are aware, but we did launch an app back about the same time as you posted your question. I believe our app does serve what you are looking for. Here is the link to our app:

https://apps.shopify.com/Recently-Added

Please take a look. We do serve up to 10 recently added items for a monthly fee of 2.99$. We are able to extend it to more if needed. This is a dynamic app that will automatically take care of your recently added products as you add them.

Let me know if you have any qustions, concerns, or even suggestions. We are working to make this app better, and we will soon update it with more features.

Hope this helps.

0 Likes
Shopify Partner
1 0 1

I know I'm late to the party but I figured out a rudimentary way to do this straight on my index.liquid (Homepage template) like so:

 

  {% assign products = collections.all.products | sort: 'published_at' | reverse %}
  {% for product in products limit:12 %}
    ({{ product.title }}) -> {{ product.id }} -> {{ product.published_at }} -> {{ product.created_at }}<br />
  {% endfor %}

 

This gets all the products from the default 'all' collection, sorts them by date published (published_at), which, will automatically sort it by ascending the published_at format is something like this: e.g.  2018-08-08 16:10:21 -0400, and then all you gotta do to get it sorted by latest to earliest is to reverse it.

 

Then, if you want to limit the listing to a few proucts just use the limit argument in the for loop.

Conversely, if you prefer to limit your products before the for loop so that you can use a snippet, for example you can do it by using the slice filter, which returns a subset of the products array / list. The first number (0) specifies which index to start at, the second number 12, specifies the number of items to return starting from the start index. So effectively it returns the items pointing to indices: 0,1,2,...,11, i.e. the first 12 items.

 

{% assign products = collections.all.products | sort: 'published_at' | reverse | slice: 0,12 %}

 

Hopefully that helps someone. I come from a WordPress background so find it ridiculous to to have to pay for an app to do something so simple like querying your products a certain way.

 

GIT-ER-DUN!!!

1 Like
New Member
4 0 0

I deleted my default "all" collection do you know how I can get it back or make another one

0 Likes