PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, May 9, 2022

[FIXED] How to shuffle products on category page when you refresh the page in magento2?

 May 09, 2022     categories, list, magento2, product, reference     No comments   

Issue

How to shuffle products on category page when you refresh the page in magento2?


Solution

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 class="Magento\Catalog\Block\Product\ListProduct" name="category.products.list" as="product_list" template="Magento_Catalog::product/list.phtml" cacheable="false">



Answered By - Shailraj
Answer Checked By - Mary Flores (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing