Magento – Magento 2 : Display Related Products Block in Product View

magento-2.1magento2related-products

I'm using magento 2.1.3 and I want to display related products under product_view. Product view is using 1 column template.

I've added successfully related products to some products. I've reindexed after adding related to products. I've cleaned cache after each change of code.

In

/vendor/magento/module-catalog/view/frontend/layout/catalog_product_view.xml

The related products block is placed in referenceContainer name="content.aside" which is not present in my product view as it is one column.

I've overridden this layout in

/app/design/frontend/myCompany/myTheme/Magento_Catalog/layout/catalog_product_view.xml

and every change is working except related products block.

I tried to move it like this

<move element="catalog.product.related" destination="content" after="product.info.main" />

I used several different destinations, even without using after/before, but related products block is not appearing anywhere.

I tried also to call it

<block class="Magento\Catalog\Block\Product\ProductList\Related" name="catalog.product.related" type="related" template="Magento_Catalog::product/list/items.phtml">
    <arguments>
        <argument name="type" xsi:type="string">related</argument>
    </arguments>
</block>

I tried even using and not using type="related" in this last way of calling, but even with or without the 'type' the block is not appearing.

Does somebody have any idea?

Best Answer

Try this:

<move element="catalog.product.related" destination="product.info.main" after="-" />

Change you XML file path from

/app/design/frontend/myCompany/myTheme/Magento_Catalog/templates/catalog_product_view.xml

To

/app/design/frontend/myCompany/myTheme/Magento_Catalog/layout/catalog_product_view.xml