Jump to content

How to find duplicate category names and remove except one in Prestashop 1.6.1.20?


sandipchandela

Recommended Posts

On 9/19/2020 at 6:28 PM, sandipchandela said:

Due to some reason, Prestashop store having lots of duplicate category aka with the same name(category title) under Home Default category(id=2).

Does any one how to find the duplicate category names in order to resolve duplication?

I don't care if any products associated will unassigned or not.

 

Hi,

I think this has happened in csv imports. Maybe there is an space " " at the end of the category name.

What I do in this cases is do one SELECT into the database (Go to Advanced parameters > Database) and check the result:

Then add a new query with this SELECT:

SELECT l.id_category, l.`name`, COUNT(cp.id_product) AS `total_products`
FROM ps_category c
INNER JOIN ps_category_lang l
	ON l.id_category = c.id_category
	AND c.active = 1
INNER JOIN ps_configuration cf
	ON cf.`name` = 'PS_LANG_DEFAULT'
	AND l.id_lang = cf.`value`
LEFT JOIN ps_category_product cp
	ON cp.id_category = c.id_category
GROUP BY l.id_category
ORDER BY l.`name` ASC

The result will show you the id_category, the name and the total products of each category.
Once you find which categories you want to delete, you have to assign manually the products to the correct category. If you directly delete the category, there will be products out the correct category. For that, go to your Product list into your backoffice and filter products by the category you want to delete. Then assign each product to the correct category and save them.

Once finished, recheck the results in the previous SELECT and see if there are 0 products there.

Now, you can delete the category. Next steps is to check:

  • Menus. Check if the link of the category is anywhere.
  • Cache. You will have to clean your cache for avoid any trouble.
  • Referal or ads links. Check if you have any external link to that category that won't work anymore

I think that's all.

  • Thanks 1
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...