How to shuffle products on category page when you refresh the page in magento2?
CodePudding user response:
Hello Mahendra try this solution!!
First Override your list.phtml file in your custom theme. Add this code in your list.phtml file.
$productArray = iterator_to_array($_productCollection); shuffle($productArray);
and add this $productArray in foreach loop.
cacheable="false" in your catalog_category_view.xml file.
<block name="category.products.list" as="product_list" template="Magento_Catalog::product/list.phtml" cacheable="false">