cancel
Showing results for 
Search instead for 
Did you mean: 

Deleted all products but still see numbers in subcategory's?

SOLVED

Deleted all products but still see numbers in subcategory's?

Hello everybody, this is my first post here.

 

I just deleted all of my products in my Magento 2.3.4 but still i see numbers next to my subcategory's. When i go to catalog / Category..

 

forum1

 

How can this be and how can i solve this?

as you can see, i have 0 products..

 

forum2

 

What can i do to make these numbers go away?

 

thank you very much for your help.

 

Kind regards,

 

Andy

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Deleted all products but still see numbers in subcategory's?

Hi @andyavcons30c7 

You can try the below query to clear the data from category mapping table.

To make sure the results. 

select * from catalog_category_product where product_id not in (select entity_id from catalog_product_entity);

To delete the records. 

delete from catalog_category_product where product_id not in (select entity_id from catalog_product_entity);

 


If you are using prefix for table then change table name accordingly.

 

I hope it will help you in future as well!

 

View solution in original post

5 REPLIES 5

Re: Deleted all products but still see numbers in subcategory's?

Hi Andy

 

Have you cleared your cache and reindexed? 

 

Reindexing will most likely solve your issues as it will "recount" all of the products in the category and show the correct number.

Chris @ Rixxo
Magento Solution Specialist, 10 year Magento user, store owner and Agency Director

Re: Deleted all products but still see numbers in subcategory's?

Thx @Rixxo i tried this in ssh with this code

 

php bin/magento indexer:reindex

and then with 

php bin/magento cache:clean

but he's still showing the number of products that aren't there :-)

 forum3forum3

Re: Deleted all products but still see numbers in subcategory's?

Would it be an option to delete everything in these table? mg_catalog_category_product ? in the sql? i see that there a still a lot of id's in there

Re: Deleted all products but still see numbers in subcategory's?

Ok, i deleted everything in mg_catalog_category_product and it worked :-) everything is back to 0.. yesss

Re: Deleted all products but still see numbers in subcategory's?

Hi @andyavcons30c7 

You can try the below query to clear the data from category mapping table.

To make sure the results. 

select * from catalog_category_product where product_id not in (select entity_id from catalog_product_entity);

To delete the records. 

delete from catalog_category_product where product_id not in (select entity_id from catalog_product_entity);

 


If you are using prefix for table then change table name accordingly.

 

I hope it will help you in future as well!