In Magento 2 you can remove the Related Items and Cross Sell items from backend manually. But what is the best way when your have large number of products and want to delete related items or cross sell items for all at once?
While I searched for the solutions, I found many articles and developers are suggested to use CSV method and choose option “Replace” instead of “Add/Update”. But the problem with this options is Magento create the new product when we go with “Replace”, it’s actually not replacing the data with the CSV columns. It creating new products for each which is not good option at all. I spent 3-4 days for solutions and last I came to easy way is to do it directly from database. It’s working fine to my site and I got success to delete all Related Items and Cross Sell items from all site products.
First you have to find the link_id from catalog_product_link_type table.
In most case 1 for Related items, 4 for Up Sell items and 5 for Cross Sell items will be there but it’s better to check once.
Now, what you need is to delete all records from
Before run the below query to do it, I suggested to keep the backup of your database, so you can easily revert back your work, if in case any problem comes.
1 2 3 4 5 | //To Remove Related Items Data DELETE FROM catalog_product_link_attribute_int WHERE link_id in (SELECT link_id from catalog_product_link where link_type_id = 1) |
1 2 3 4 5 | //To Remove Upsell Items Data DELETE FROM catalog_product_link_attribute_int WHERE link_id in (SELECT link_id from catalog_product_link where link_type_id = 4) |
1 2 3 4 5 | //To Remove Cross Sell Items Data DELETE FROM catalog_product_link_attribute_int WHERE link_id in (SELECT link_id from catalog_product_link where link_type_id = 5) |
Hello, every time i used to check website posts here in the early hours in the break of day, because i enjoy to find out more and more.