zapmore Posted July 16, 2013 Share Posted July 16, 2013 (edited) I have the following scenario: MainCat3All Products within MainCat3 SubCat1 SubCat2 SubCat3 etc. I want to add a link "All products within MainCat3" in the meny, I noticed that a lot of costumers miss that they actually can click "MainCat3". So how would i do to include products from specific categories into another category without going in the each products and attach the category. I was thinking a SQL command or a php code but don't want to try it out blind and break everything.... I'm using prestashop v1.5.4.1 Would something like this work that I found in another old thread: INSERT INTO `ps_category_product` SELECT 8, `id_product`, 0 FROM `ps_product` WHERE `id_category` = 7 AND `id_category` = 9 AND `id_category` = 10 Edited July 23, 2013 by zapmore (see edit history) Link to comment Share on other sites More sharing options...
scorpionsworld Posted July 16, 2013 Share Posted July 16, 2013 I have the following scenario: MainCat3All Products within MainCat3 SubCat1 SubCat2 SubCat3 etc. I want to add a link "All products within MainCat3" in the meny, I noticed that a lot of costumers miss that they actually can click "MainCat3". So how would i do to include products from specific categories into another category without going in the each products and attach the category. I was thinking a SQL command or a php code but don't want to try it out blind and break everything.... I'm using prestashop v1.5.4.1 Would something like this work that I found in another old thread: INSERT INTO `ps_category_product` SELECT 8, `id_product`, 0 FROM `ps_product` WHERE `id_category` = 7 AND `id_category` = 9 AND `id_category` = 10 If you want to add products from either one of the SubCat's you should use the OR switch in the SELECT statement. Link to comment Share on other sites More sharing options...
zapmore Posted July 16, 2013 Author Share Posted July 16, 2013 If you want to add products from either one of the SubCat's you should use the OR switch in the SELECT statement. Yes, I want to add all products in these categories. Is these tables correct in Prestashop 1.5.4.1 for what I want to accomplish? I'm afraid to brake the db... Link to comment Share on other sites More sharing options...
scorpionsworld Posted July 16, 2013 Share Posted July 16, 2013 Yes, I want to add all products in these categories. Is these tables correct in Prestashop 1.5.4.1 for what I want to accomplish? I'm afraid to brake the db... These tables are correct. I've tested the query myself and it wont break anything Link to comment Share on other sites More sharing options...
zapmore Posted July 17, 2013 Author Share Posted July 17, 2013 These tables are correct. I've tested the query myself and it wont break anything Lovely! Thank you for your input! Link to comment Share on other sites More sharing options...
zapmore Posted July 22, 2013 Author Share Posted July 22, 2013 I used this SQL code but got error message, I thought it was because the category table is called "id_category_default" instead of "id_category" so I changed to the following: INSERT INTO 'ps_category_product' SELECT 44, 'id_product', 0 FROM 'ps_product' WHERE 'id_category_default' = 25 OR 'id_category_default' = 26 OR 'id_category_default' = 27; However I get the following error message: #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''ps_category_product' SELECT 44, 'id_product', 0 FROM 'ps_product' WHERE 'id_cat' at line 1 What is the problem? Link to comment Share on other sites More sharing options...
scorpionsworld Posted July 22, 2013 Share Posted July 22, 2013 I used this SQL code but got error message, I thought it was because the category table is called "id_category_default" instead of "id_category" so I changed to the following: INSERT INTO 'ps_category_product' SELECT 44, 'id_product', 0 FROM 'ps_product' WHERE 'id_category_default' = 25 OR 'id_category_default' = 26 OR 'id_category_default' = 27; However I get the following error message: #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''ps_category_product' SELECT 44, 'id_product', 0 FROM 'ps_product' WHERE 'id_cat' at line 1 What is the problem? And what was the first error, before you changed the query to id_category_default? Link to comment Share on other sites More sharing options...
zapmore Posted July 22, 2013 Author Share Posted July 22, 2013 And what was the first error, before you changed the query to id_category_default? It works now with id_category_default, the problem was that I was using ' instead of ` I always thought ' was the right thing to use.. sorry for your trouble. 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