Pete Nice Posted March 3, 2014 Share Posted March 3, 2014 Hi, I'm trying to show the products from 2 categories on one category page. I've created a blank category and assigned a custom category template with an override CategoryController.php. Can anyone show me an example of a function to get the products from two categories? Link to comment Share on other sites More sharing options...
Dh42 Posted March 4, 2014 Share Posted March 4, 2014 Can you not just assign all of the products to both categories? Link to comment Share on other sites More sharing options...
Pete Nice Posted March 4, 2014 Author Share Posted March 4, 2014 (edited) I have a clothing store that has separate categories for Men & Women. I want to combine both of the 'New Arrivals' categories on one page so the products need to stay in their respective categories. Edited March 4, 2014 by Pete Nice (see edit history) Link to comment Share on other sites More sharing options...
Dh42 Posted March 4, 2014 Share Posted March 4, 2014 Prestashop has a built in category for new products. Have you tried using that? Link to comment Share on other sites More sharing options...
Pete Nice Posted March 4, 2014 Author Share Posted March 4, 2014 Yes I could use that category but I like the flexibility of which products can be added to each independent new arrivals category. Surely someone can point me in the right direction to create a function to pull products from both categories? Link to comment Share on other sites More sharing options...
vekia Posted March 4, 2014 Share Posted March 4, 2014 $this->category2 = new Category(10, $this->context->language->id); $this->cat_products2 = $this->category2->getProducts($this->context->language->id, (int)$this->p, (int)$this->n, $this->orderBy, $this->orderWay);$this->cat_products = array_merge($this->cat_products, $this->cat_products2); voila Link to comment Share on other sites More sharing options...
Pete Nice Posted March 4, 2014 Author Share Posted March 4, 2014 (edited) So I modified the homefeatured module to get the products from 2 categories and merged the resulting arrays. EDIT - Ha! Thanks I'd just figured that out. Edited March 4, 2014 by Pete Nice (see edit history) Link to comment Share on other sites More sharing options...
Pete Nice Posted March 4, 2014 Author Share Posted March 4, 2014 Thanks, I actually used your method to customise my CategoryController rather than add a module Link to comment Share on other sites More sharing options...
vekia Posted March 5, 2014 Share Posted March 5, 2014 you can also use shuffle($this->cat_products), products will be shuffled then Link to comment Share on other sites More sharing options...
Chris2013 Posted March 5, 2014 Share Posted March 5, 2014 Hi Guys I was trying to the the same, however unlike you two I'm a little lost when it comes to the php smarty stuff. If you have time I wonder if either of you could explain the way you achived it and the code used, as I wouldnt mind learning how you made it work. Thanks In Advance @Pete, Questlove, qaulity drummer, roots qaulity band :-) Link to comment Share on other sites More sharing options...
vekia Posted March 5, 2014 Share Posted March 5, 2014 Hi Guys I was trying to the the same, however unlike you two I'm a little lost when it comes to the php smarty stuff. If you have time I wonder if either of you could explain the way you achived it and the code used, as I wouldnt mind learning how you made it work. Thanks In Advance @Pete, Questlove, qaulity drummer, roots qaulity band :-) where exactly you want to change it? for what part of website? Link to comment Share on other sites More sharing options...
Chris2013 Posted March 5, 2014 Share Posted March 5, 2014 (edited) Hi Vekia Thanks for taking the time to repley. Like Pete, i would like to have 2 catagories display on one page as I also need the flexability to select want product show in those categories For example I have an on sale catagory , on that page I want to show to fashion labels that are on sale but not all mixed up, I would like to have them like below Sale ---label 1 ---- all the items here ---label 2 ---- all the items here I see the code you have written and looked at the CategoryController but I don't understand how you implemented it. Chris Edited March 5, 2014 by Chris2013 (see edit history) Link to comment Share on other sites More sharing options...
IndiaLinkers Posted April 29, 2014 Share Posted April 29, 2014 Hi vekia, I need to put same functionality on hamepage replacing featured products. Deepanshu Goel Link to comment Share on other sites More sharing options...
MVS__ Posted October 9, 2017 Share Posted October 9, 2017 Hey guys, I have the following problem: I have Cat1 and Cat2. When somebody enters in Cat1, I want to list: Cat1 - products from Cat1 Cat2 - products from Cat2 Similar when they enter Cat2, to have a label Cat2 and the products from Cat2, and label Cat1 and products from Cat1. I tried the code that Vekia said, but I didn't understand where to assign Cat2 to Cat1 and Cat1 to Cat2 Can you please help me? Thanks, Madalin Link to comment Share on other sites More sharing options...
Recommended Posts