Jump to content

Randomize product List


Recommended Posts

Hi to all,

currently I'm on prestashop 1.6.1.6 with a TrailMix theme. I need to randomize the product list of a specific category by showing all of the products that can be shown in each page (so the last paramether is (int)$this->n).

 

Currently the CategoryController in the assignProductList() function has the code:

 

if(((int)$this->category->id_category) == 77 || ((int)$this->category->id) == 77) {
$this->cat_products = $this->category->getProducts($this->context->language->id, (int)$this->p, (int)$this->n, $this->orderBy, $this->orderWay,false, true, true, (int)$this->n);
               /*if((int)$this->category->id_category == 77) {
                  $toShuffle = $this->cat_products;
                  shuffle($toShuffle);
                  $this->cat_products = $toShuffle;
                }*/
} else {
$this->cat_products = $this->category->getProducts($this->context->language->id, (int)$this->p, (int)$this->n, $this->orderBy, $this->orderWay);
}

 

But the products are shown without random criteria. I've also tried to disable/enable blocklayered and clean the cache without having success. I've put the die instruction in the initContent method of the controller and it is the controller that is used (test message is shown) so I'm modifying the correct controller.

 

I've already seen the topics over older prestashop versions and applied the solutions suggested but the problem isn't solved:

 

https://www.prestashop.com/forums/topic/437113-random-product-arrangement-in-product-listing-in-16/?hl=random

 

https://www.prestashop.com/forums/topic/372924-random-product-order-only-for-specific-category/

 

Someone can help me please?

 

Thank you.

Luca

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...