Jump to content

How to display all product?


limon213

Recommended Posts

Hello, I want to display all product list in one page. How do I do it? Or Is there any module for this? 

 

Thanks 

 

Hello, Your Idea is nice. But I have 126 product :( It will be too tough to assign each product manually to all product category. Is there any alternative way? If I create a page and query all product there? Any more solution? 

 

Thanks 

Edited by limon213 (see edit history)
Link to comment
Share on other sites

That will work and will probably more user-friendly than an SQL query, but I'll write it here just in case anyone needs it. You can run an SQL query like the following in phpMyAdmin:
INSERT INTO `ps_category_product` (`id_category`, `id_product`)
​SELECT 123, `id_product`
​FROM `ps_product`;

SELECT @i:=-1;
UPDATE `ps_category_product` SET `position` = @i:=@i+1
​WHERE `id_category` = 123;

Change ps_ to your database prefix if it is different and 123 to the ID of the "All Products" category you created. This will add all the products to the "All Products" category and then give them all appropriate positions.

 

Note that this query relies on the "All Products" category having no products associated with it. You can use a query like the following to delete existing associations before running the above if needed:

DELETE FROM `ps_category_product` WHERE `id_category` = 123

Change ps_ to your database prefix if it is different and 123 to the ID of the "All Products" category you created.

  • Like 1
Link to comment
Share on other sites

 

That will work and will probably more user-friendly than an SQL query, but I'll write it here just in case anyone needs it. You can run an SQL query like the following in phpMyAdmin:
INSERT INTO `ps_category_product` (`id_category`, `id_product`)
​SELECT 123, `id_product`
​FROM `ps_product`;

SELECT @i:=-1;
UPDATE `ps_category_product` SET `position` = @i:=@i+1
​WHERE `id_category` = 123;

Change ps_ to your database prefix if it is different and 123 to the ID of the "All Products" category you created. This will add all the products to the "All Products" category and then give them all appropriate positions.

 

Note that this query relies on the "All Products" category having no products associated with it. You can use a query like the following to delete existing associations before running the above if needed:

DELETE FROM `ps_category_product` WHERE `id_category` = 123

Change ps_ to your database prefix if it is different and 123 to the ID of the "All Products" category you created.

 

 

 

Thank you very much. It saves my lot of time   :)

Edited by limon213 (see edit history)
Link to comment
Share on other sites

  • 1 year later...

hello

Nice script.
I test it in my phpmyadmin, i add a new category id 158 name " all products ".
I add it to the mysql:

INSERT INTO `ps_category_product` (`id_category`, `id_product`)
SELECT 158, `id_product`
FROM `ps_product`;

SELECT @i:=-1;
UPDATE `ps_category_product` SET `position` = @i:=@i+1
WHERE `id_category` = 158;

All i get is error :(

Can some one help me, i have over 1200 products,  and i don´t whant to take one by one.

P.S i fix it myself, i asign a product to the category, and then i add the mysql code to phpmyadmin, and all works :)

Thanks...

Edited by spc (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...