YiannisK Posted July 17, 2013 Share Posted July 17, 2013 I want to change NewProductsController.php to get products from specific category. I have copied the file to /override/controllers/front folder but I don't know what to do. I want to get the category ID (and use the subcategories also) using GET variables from a custom link and filter the products of this category/subcategories. eg. www.mysite.com/new-products?cg=3 I don't want to change the Product class, so I want to take the array 'products' => Product::getNewProducts($this->context->language->id, (int)($this->p) - 1, (int)($this->n), false, $this->orderBy, $this->orderWay), and create a new array only with the products in category 3 (cg=3) and all subcategories. Is this possible? Thanks!! 1 Link to comment Share on other sites More sharing options...
linyinlu Posted November 4, 2013 Share Posted November 4, 2013 (edited) Right now, I currently switch the "New Products Block" into specific products. To do so, you have to change the function getNewProducts in "classes/Products.php". From (in Line 2014): WHERE product_shop.`active` = 1 Into: WHERE (product_shop.`active` = 1 AND product_shop.`id_category_default`=2) And in line: 2044 $sql->where('product_shop.`active` = 1') change to: $sql->where('product_shop.`active` = 1 AND product_shop.`id_category_default` = 2'); Therefore, the New products will show all products which default category is 2. Forgot to mention, my prestashop version is 1.5.6. Edited November 4, 2013 by linyinlu (see edit history) Link to comment Share on other sites More sharing options...
ShowYou Posted November 14, 2013 Share Posted November 14, 2013 Hi, Is it possible to define a category but not a default category ? I try to join table ps_category_product but it don't find the best solution. Link to comment Share on other sites More sharing options...
linyinlu Posted November 22, 2013 Share Posted November 22, 2013 Hi, Is it possible to define a category but not a default category ? I try to join table ps_category_product but it don't find the best solution. Change the structure of the table, add a column "New_Products_Category" and changes the code accordingly? It may useful. But please remember to backup your database before you made any changes. Link to comment Share on other sites More sharing options...
ShowYou Posted November 22, 2013 Share Posted November 22, 2013 Hi, It's a good idea. I haven't think about it... I have added 2 columns yet then i can do it. Thanks. PS : I make a backup every day.... ;-) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now