I have a problem concerning the cross-sell links. I'm building a custom module and I need to add and delete cross-sell links according to a product.

I know how to create the cross-sell links using:


But what I don't know is how to remove cross-sell links.

Is there a function to do that or have I to execute an SQL request to delete the links from magentocatalog_product_link inside my module (which isn't a good practice) ?

Thank you for your help


Easiest way:

Get cross sell product ids:

$crossSellLinkData = $product->getCrossSellProductIds();

Flip array so that product ids in the array are key values:

$crossSellLinkData = array_flip($crossSellLinkData);

Then, unset the product you want to remove:


Then set and save:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.