Jump to content

Random product order only for specific category


Recommended Posts

Hey guys, 

 

This have been asked a few times but then people have been wanting to do it for all categories, but I wanna do this just for a specific category. I wanna have one category page, that only shows 6 products, and those to be randomized from all products within that category.

 

I've successfully change the amount of products shown per page and also calling a custom category.tpl for specific categories by putting if statements in CategoryController.php and FrontController.php. Also manage to hide the header and footer for these, so I kinda know why way arround.

 

I've found this solution http://www.prestashop.com/forums/topic/302732-random-product-listing/

 

...and it kinda works, it randomizes the products but it only shows one product. This is what I have in my CategoryController.php now (in the assignProductList function):

 

if ($this->category->id==25) {

$this->cat_products = $this->category->getProducts($this->context->language->id, (int)$this->p, (int)$this->n, $this->orderBy, $this->orderWay,false,true,true);

} else {

$this->cat_products = $this->category->getProducts($this->context->language->id, (int)$this->p, (int)$this->n, $this->orderBy, $this->orderWay);

}

 

Any takers?

 

All help, pointer and suggestions are welcome! 

 

Thanks in advance!

 

/A

Link to comment
Share on other sites

Solved it! :D

 

Should be:

 

$this->cat_products = $this->category->getProducts($this->context->language->id, (int)$this->p, (int)$this->n, $this->orderBy, $this->orderWay,false,true,true,6); 
...the last nr is the amount of products that get picked, default is 1 so therefor only one showed up. Edited by anmihe (see edit history)
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...