Related products

Related products are products which are, well, related to a product in some way - they are displayed on the product page in a separate section, as in Figure 1.1.

Figure 1.1 Related products

The nature of the relationship - e.g. Wheels for this bike above - is defined under a relation group. Relation groups are typically solution-specific, which means that you have to create a new set of relation groups for each project.

To create a relation group:

  • Go to Settings > Ecommerce > Product catalog > Relation groups
  • Create a new relation group (Figure 1.2) and name it
  • Click Save and close
Figure 1.2 Create a new relation group

Once the relation group is created, you can use it to add related products to a product:

  • Go to the Ecommerce area and open the product details for your product 
  • In the ribbon bar, click Related products to open the related products interface
  • Click Add related products and select your relation group (Figure 1.3)
Figure 1.3 Add the relation group to your product
  • Mark the products that should be shown as related products
  • Click Save and close
Figure 2.1 Select your related products

Now the products index must be rebuild, and because this is a brand new relation group, you must build it manually to index the new relation group as well - the auto-build index functionality doesn't register new relation groups. So:

  • Go to Settings > Repositories > Products
  • Open the Products index
  • Rebuild one of our instances (Figure 2.2)
  • Save and close
Figure 2.2 Rebuild the products index

However, if you use an existing relation group and have just added added new related products, then the relation group is already registered. That means you don't need to do anything (that is, if your shop is set to auto-build the products index when products are updated. If that's not the case, then you must still rebuild the index manually, but you don't need to do the next steps).

This rebuild accomplished two things - the product relation is indexed, and the new relation group is indexed and can now be added to the summary field used to query for related products. So to get your related products shown in frontend, you must:

  • Enter the Products index again
  • Under Fields, find and click the Related product search field
  • Add the new relation group to the list of source fields (Figure 3.1)
  • Click OK and save the index
Figure 3.1 Adding a new relation group to the related products search field

Now, go to the Products query. Add a new parameter (Figure 3.2) and name it the same as your relation group, but without spaces and every new word capitalized. Set the type as System.String[].

Figure 3.2 Add a new parameter matching your relation group

Scroll down to the bottom of your Expressions, and add an expression (Figure 3.3).

  • Select your new relation group
  • Set the condition to MatchAny
  • Using the pencil icon, set the value to Parameter > your new parameter for your relation group
Figure 3.3 Add an expression to match the relation group to your new parameter

Now open the product page in frontend - you should see related products rendered under the relation group name, as in Figure 4.1.

Figure 4.1 End result in frontend