Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- foreach($collection as $p) {
- $upsell = $p->getUpSellProductIds();
- if ( count($upsell) > 0 ) {
- $toUpdate = false;
- foreach ($upsell as $k => $u) {
- // Check if the entity_id is among the discontinued products
- if ( isset($discontinued[ $u ]) ) {
- // Remove the discontinued entity from the up-sells list
- unset($upsell[$k]);
- $toUpdate = true;
- }
- }
- if ($toUpdate) {
- $upsellToSave = array();
- foreach ($upsell as $u) // Formatting the data
- $upsellToSave[ $u ] = array('position'=>'');
- try {
- $p->setUpSellLinkData($upsellToSave)->save();
- } catch (Exception $e) {
- echo "Problem saving up-sell data.\n";
- }
- }
- }
- }
- // http://magento.stackexchange.com/posts/130802
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement