Markets specifik products, still rendered on storefront

Hey everyone!

How does one filter out products in liquid, that isn’t published to the current market?
I.e. if i have 2 different markets, the product i published on only one of dem.

If i create a metaobject, and select the products via a product picker, I can still render the items via liquid on the storefront, but will always get a 404 page in return, and can’t add to cart because it doesn’t exist on the current market.

Seems like a bug, would be nice if Shopify handled that logic, or allowed a property on the product object, determing which markets it’s published on.

Found a workaround, but doesn’t seem logical that it should be handled like that on the frontend.
If accessing the actual product from the all_products[handle] and then validating on any info returned from that, it works for specific markets.

Hi Tobias, I’m glad to hear that you found a workaround for your issue. Id like to better understand the problem though so I can bring it back to our development team. Is the issue that you wish to render the same collection of products across multiple markets but to apply filtering on the collection within a specific market?

If this is your usecase, the way I would have suggested to try is to create a separate collection with your market specific products. Then contextually override the data source for that market to render this separate collection. Ensuring that only expected products will render for a certain market would be a more predictable way to get your desired set up.

That said, filtering on client-side is a more dynamic solution if you have a bunch of these nuanced products and do not wish to make separate market specific collections.

1 Like

Had a similar issue with a custom wishlist setup. Using all_products as filter works, but only for handles (not product ids) and up to 20 per page.
The workaround was storing a json list of handles instead of a list of product references, paginating by 20, and posting a notice “change your market” if the list of filtered items was smaller than before the filter.
Would prefer if all_products handled product ids (maybe also variant ids?) and had a higher limit than 20 per instance.

Hi Albort!

The issue were that when using markets, and using metaobjects with a product picker, you can still render all the products on all markets, even though the products doesn’t exist on that market.

It’s kind of like rendering products that are draft on the storefront, and then when trying to visit the product, you land on a 404 page, or when you try adding to cart, it just errors.

Exactly, why it would be nice to either be handled by Shopify, not allowing rendering of products when not existing on the market, or alternatively add some property on the product object, with markets data, on which it’s published on and so on.