1

I'm using Magento 2.0.2.

I want to display a random collection of products from the catalog on my home page. In the CMS for my home page, i use the following code:

<p>{{block type="catalog/product_list_random" template="catalog/product/list.phtml" num_products="12"}}</p>

<hr />

<p>{{widget type="Magento\CatalogWidget\Block\Product\ProductsList" products_count="4" template="product/widget/content/grid.phtml" conditions_encoded="a:1:[i:1;a:4:[s:4:`type`;s:50:`Magento|CatalogWidget|Model|Rule|Condition|Combine`;s:10:`aggregator`;s:3:`all`;s:5:`value`;s:1:`1`;s:9:`new_child`;s:0:``;]]"}}</p>

The product_list_random block displays nothing, but the widget displays products just as I would expect.

Why does the block render nothing at all? How can I display a collection of random products on the home page?

1 Answer 1

3

You have to use the attribute class instead of type. Magento 2 got rid of class aliases such as core/template or core/text_list

{{block class="Magento\Catalog\Block\Product\ProductList\Random" template="product/list.phtml" num_products="12"}}

This will work

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.