LemonStand Documentation

Displaying related products

Displaying related products is a simple task, if you have followed our advice to create a separate partial for displaying a product list.

You can obtain a collection of related products with the list_related_products() method of the $product object. The following code demonstrates how you can output a list of related products using the partial you created before.

The code checks whether any related products were assigned to the current products and outputs the header “Related products”. Then it renders the shop:product_list partial passing a result of the list_related_products() method call as a collection of products into the product list partial.

You can duplicate the shop:product_list partial and modify it if you need another way of displaying the related products.

See also:

Next: Displaying product manufacturer information
Previous: Displaying product extra options
Return to Product page