Have your say in Community Polls: What was/is your greatest motivation to start your own business?

Moving a product to the beginning of a manually sorted collection when back in stock

Moving a product to the beginning of a manually sorted collection when back in stock

specklefarms
Excursionist
37 1 11

I have a collection with all of my products.

 

I would like the ones that are back in stock to move to the front of a collection. I'm assuming this would have be "manually sorted".

 

Is there a way to do this?

 

I'm looking at the Get collection data in the Shopify Flow documentation as an action when this is triggered, but I'm lost with how I can program the Flow, since I'm not great with Liquid.

 

Any guidance would be amazing.

Replies 4 (4)

FurtherRecords
Shopify Partner
37 1 18

Following because I also need to do this. 

 

I have a "back in stock" collection. My current method is to automate removal from the collection when item goes out of stock. Auto add to collection when comes back in stock (both using Flow) and then go to the collection every few days/weeks as needed and ticking all the items at the bottom of the collection and "move to top". 

 

It's far from ideal.

Kalen_Jordan
Shopify Partner
779 36 141

I think it should be possible with a custom collection, because you can set the sort order via the API. I don't believe you can set the sort order of a smart collection over the API.

Kalen_Jordan
Shopify Partner
779 36 141

This is the mutation that you want to use to change the order of products in the collection:

https://shopify.dev/docs/api/admin-graphql/2023-10/mutations/collectionReorderProducts

 

Screenshot 2023-12-04 at 2.44.27 PM.png

 

I built out a workflow template this morning to do this using our 3rd party app - I'm guessing you should be able to do it in flow though. You'll just need a data store to keep track of the previous inventory so that you can track when the inventory went from zero to positive.

 

specklefarms
Excursionist
37 1 11

Here is an update on a solution that is working well for my site.

 

This is solved with a handful of moving pieces using Shopify Flow and a Sorting App our web devs have us using for several other functions.

 

  1. I created a new Time and Date metafield definition for my product pages.
  2. I set up a Flow that will update the product's Time and Date metafield.
  3. I set up a collection that contains only products with an inventory greater than 0.
  4. The third-party app has a Sort feature that will sort by Time and Date on the metafield. The collection's Time and Date sorting is managed by the app, which allows me to set different default Sorting views on a collection basis.

The only issue I had with this was that the third-party app wasn't designed to sort metafields by Time and Date, but I contacted them and their team was able to add it to the server side. They didn't make it clear whether my site is the only one to handle this, or if they built this feature into all of their clients.

 

Hope this helps.