Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Remove Product Related, Upsell and Cross-sells Programmatically
 
duhdias
Jr. Member
 
Total Posts:  14
Joined:  2011-01-26
 

Hi,

I am updating some products programmatically, and need to remove the relationship from product with Product Related, Upsell and Cross-sells… But I just got update.

To add or update I am using:

//for related
$_product->setRelatedLinkData($param);
//for up-sells
$_product->setUpSellLinkData($param);
//for crosssells
$_product->setCrossSellLinkData($param);

How I unset all relationship?

Thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
tzyganu
Mentor
 
Avatar
Total Posts:  2205
Joined:  2009-11-18
Bucharest, Romania
 

Hello.
What happens if you set the parameter as an empty array ?

//for related
$_product->setRelatedLinkData(array());
//for up-sells
$_product->setUpSellLinkData(array());
//for crosssells
$_product->setCrossSellLinkData(array());

Marius.

 
Magento Community Magento Community
Magento Community
Magento Community
 
duhdias
Jr. Member
 
Total Posts:  14
Joined:  2011-01-26
 
tzyganu - 17 April 2013 12:51 AM

Hello.
What happens if you set the parameter as an empty array ?

//for related
$_product->setRelatedLinkData(array());
//for up-sells
$_product->setUpSellLinkData(array());
//for crosssells
$_product->setCrossSellLinkData(array());

Marius.

The code is at my work, but I tried it and nothing happens.

 
Magento Community Magento Community
Magento Community
Magento Community
 
tzyganu
Mentor
 
Avatar
Total Posts:  2205
Joined:  2009-11-18
Bucharest, Romania
 

Are you sure it doesn’t work like that? It worked for me on Magento 1.7.0.2.
Here is what I’ve tried for related products:

$product->setRelatedLinkData(array())->save();
Worked perfectly.
 
Magento Community Magento Community
Magento Community
Magento Community
 
duhdias
Jr. Member
 
Total Posts:  14
Joined:  2011-01-26
 

Hi I see my code today I and had tried:

$product->setCrossSellLinkData();

Using array() really worked.

Thanks

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top