Shopify Related Products

I was looking for a way to control the related products shown below a product (for cross-selling) without using an external app, and came up with a very basic and easy to use template and collection solution.

In the theme I am using the related products are taken from the same collection, which is a good start, but for some collections I would like to be able to select a set of products that I want to show below the products.

So for every collection that I want to display certain products, I create a new collection with the same name and _Related behind it. (so if the product collection is called Shoes, I will create a new collection Shoes_Related, and add the products I want to display below the shoes products to this collection)

In my related-products.liquid file, I will check if a collection with the same name and _Related exists:

Now if no Related collection is found, I will revert back to the ‘normal’ behaviour, getting a few items from the same collection and displaying them:

 

 

So the complete code from my related-products.liquid looks like: