Jump to content

Bulk removal of items from the Home category


Zedster

Recommended Posts

Hello,

 

We are a couple of people that do not have much experience with PrestaShop. So, when we were adding products to the catalog we almost always set a check mark in the Home category.  Well now there are way too many items in that category. This makes the "Featured products on the homepage" module no fun to work with. 

 

So my question is there a bulk edit those items or am i doomed to open 1500 item one at a time?

 

Thanks for any help.

 

-Jeff

Link to comment
Share on other sites

You can log in to your phpMyAdmin, back up the `ps_category_product` table in case you need to restore it, and then run an SQL query like the following:

DELETE FROM `ps_category_product` WHERE `id_category` = 2;
INSERT INTO `ps_category_product` (`id_category`, `id_product`, `position`) VALUES (2, 10, 0), (2, 11, 1), (2, 12, 2);

Change ps_ to your database prefix if needed. This will remove all products from the "Home" category (unless you're using an old version of PrestaShop before the "Root" category was added) and then add products 10, 11 and 12 to the "Home" category positioned in that order. You can change the second parameter to whichever products you want to be in the "Home" category and the third parameter to whatever order you want them displayed.

Link to comment
Share on other sites

You can log in to your phpMyAdmin, back up the `ps_category_product` table in case you need to restore it, and then run an SQL query like the following:

DELETE FROM `ps_category_product` WHERE `id_category` = 2;
INSERT INTO `ps_category_product` (`id_category`, `id_product`, `position`) VALUES (2, 10, 0), (2, 11, 1), (2, 12, 2);

Change ps_ to your database prefix if needed. This will remove all products from the "Home" category (unless you're using an old version of PrestaShop before the "Root" category was added) and then add products 10, 11 and 12 to the "Home" category positioned in that order. You can change the second parameter to whichever products you want to be in the "Home" category and the third parameter to whatever order you want them displayed.

OK thanks so much for your reply.  I have just now gotten the chance to try this and it does not seem to work for me. You mention something about old versions. I am using 1.5.6.2.

 

When I run the query DELETE FROM `ps_category_product` WHERE `id_category` = 2; I get this feedback: 0 rows deleted. ( Query took 0.0058 sec ). so nothing is being deleted. Will say that my version lists the "Home" catergory as "Menu".  I assumed this was because we use the program in Danish. Any suggestions for this?

 

Thanks again.

Link to comment
Share on other sites

Yes, it appears your home category has an ID of 1 instead of 2 for some reason. Perhaps you used the CSV import and it replaced the root category with the home category.

 

Anyway, the important thing is that my SQL queries should work if you change the ID to 1.

Link to comment
Share on other sites

Or an upgrade from PS 1.4...

Wow you really are full of great advice.  Yeah we tried to upgrade but it caused us to lose our entire site for 2 weeks and another week to get it rolled back to a usable site again.  And since we will not pay Presta 600 euro to upgrade their product there will be no upgrade at this point. Also, if you are going to troll a thread get it right, we are at version 1.5 not 1.4.

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

Yes, it appears your home category has an ID of 1 instead of 2 for some reason. Perhaps you used the CSV import and it replaced the root category with the home category.

 

Anyway, the important thing is that my SQL queries should work if you change the ID to 1.

 

I really do appreciate the help here. But I now have gotten a chance to try this with the ID 1 and this time it did change 15 lines but it should have changed around 1500. 

 

Now I think that my question was not phrased properly.  For example, let's take a pair of mens work pants. Under "associations" there is a check mark in, Menu (Home), clothing, work clothes, Industry, and finally pants. So when I am looking at the actual ps_category_product table I can see that none of them list id_category as being 1 (or 2 for that matter) It looks like they list the number associated with the final child branch id number, meaning that when I look at the at the association page for a product it still has Home with a check mark. So my list for featured products is still very overwhelming. We can live with our mistake but I a was hoping for a easy resolution for this. 

 

Thanks again.

Link to comment
Share on other sites

I was sure that would work, since the "Featured products on the homepage" module gets all products in the "Home" category by default.

 

I had a look at my PrestaShop v1.6.1.6 test site and I can see it's possible to change the ID of the category to get products from. If you have that option too, you could create a new category called "Featured Products" and enter it's ID on the configuration page. That way, you can start anew and tick only the products you want.

Link to comment
Share on other sites

I was sure that would work, since the "Featured products on the homepage" module gets all products in the "Home" category by default.

 

I had a look at my PrestaShop v1.6.1.6 test site and I can see it's possible to change the ID of the category to get products from. If you have that option too, you could create a new category called "Featured Products" and enter it's ID on the configuration page. That way, you can start anew and tick only the products you want.

I will give that a shot when I get a chance. Thanks so much again.

Link to comment
Share on other sites

  • 7 years later...

Thank you! This helped me, but unfortunately in the products section I still see HOME.

But if you go into product properties, then everything is fine. Clearing cache on website  and in browser does not change anything.

P.S. I only did DELETE FROM `ps_category_product` WHERE `id_category` = 2;

Prestashop 8.1.3

Снимок экрана 2024-01-22 в 12.59.31.png

Снимок экрана 2024-01-22 в 13.01.17.png

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...