How to add the related products block to Magento 2?

How to get Magento 2 related products?

To get Magento 2 related products, you can use native Magento settings or 3rd-party extensions. The open-source version of Magento allows you to add related products by choosing them manually from the list. It may take forever for stores that have several thousand products in the catalog. In that case, it’s easier to install an extension that will display related products automatically according to the specific rule.

What to do if Magento 2 related products are not showing?

There are a couple of common reasons why Magento 2 related products are not showing. In most cases, you can solve the problem by flushing the Magento cache or/and reindexing the data. For this, you need to log in to the Magento server as the Magento file system owner and run the following CLI commands:
php bin/magento indexer:reindex
php bin/magento cache:flush

How to add related products to Magento 2 programmatically?

If you still need to add related products to Magento 2 programmatically, we recommend hiring our dedicated development team. Thus, you don’t need to be a professional Magento 2 developer by yourself and can delegate the complicated task of getting Magento 2  related products programmatically to specialists. Learn more about our custom development service or leave a request.

Displaying the related-products block on product pages can increase the revenue by up to 30% on average. So let’s see 2 methods of how you can get related products in Magento 2 without any programming skills.

Method 1. Vanilla Magento 2 settings

Step 1. Log in to your admin panel and navigate to Catalog > Inventory > Products.

Step 2. Find the needed product from the list and click the Edit button.

Step 3. Find the Related Products, Up-Sells, and Cross-Sells section and open it.

Step 4. Then click the Add Related Products button.

Step 5. Use filters to find products that you want to display as related and select them by clicking on the checkbox.

Step 6. When you are ready, click the Add Selected Products button and save the product.

Repeat these steps for all the products on which pages you want to configure the block.

The same way you can get not only the Magento 2 related products block but also up-sells and cross-sells.

Method 2. Automatic related products

The Automatic Related Products extension allows you to create rules that add related products to any CMS page automatically and improve Magento's search of products programmatically.

After you install and set up the plugin, go to Catalog > Amasty Related Products > Related Product Rules and create a new rule. There you can specify the block position on the page, to what products you want to add this block, and what items should be shown or not shown as related products on Magento 2 frontend. 


For example, you can configure that for all products from the category laptops goods from categories: computer mice, laptop stands, and laptop bags will be shown as related. Moreover, you can use these rules to offer cross-sells and upsells products. You can enable the Same as condition and set up additional attribute value to display in this block. 


Besides, the extension allows you not only add related products to Magento 2 pages programmatically but also create bundle packs and offer valuable deals.


How can we help you?

Didn’t you find the answer to your question? We are always happy to help you out.