2

We try to update some store views with the following command:

Mage::getSingleton('catalog/product_action')->updateAttributes(array($foundProductID), array('name' => $language['name'], 
              'short_description' => $language['shortDescription'], 
              'description' => $language['desciption'], 
              'meta_description' => $language['metaDescription'], 
              'meta_keyword' => $language['metaKeyword'], 
              'meta_title' => $language['title']), $storeID);

Then we get this error message:

Fatal error:
Uncaught exception 'Exception' with message 'Warning: Invalid argument supplied for foreach() in app/code/core/Mage/Index/Model/Event.php on line 167' in app/code/core/Mage/Core/functions.php:245 Stack trace:
#0 app/code/core/Mage/Index/Model/Event.php(167): mageCoreErrorHandler(2, 'Invalid argumen...', '/var/www/magent...', 167, Array)
#1 app/code/core/Mage/Index/Model/Event.php(199): Mage_Index_Model_Event->_mergeNewDataRecursive(false, Array)
#2 app/code/core/Mage/Index/Model/Resource/Event.php(67): Mage_Index_Model_Event->mergePreviousData(Array)
#3 app/code/core/Mage/Core/Model/Resource/Db/Abstract.php(423): Mage_Index_Model_Resource_Event->_beforeSave(Object(Mage_Index_Model_Event))
#4 app/code/core/Mage/Core/Model/Abstract.php(318): Mage_Core_Mode in app/code/core/Mage/Core/functions.php on line 245

We have to update huge amounts of products. That's why we try to use

Mage::getSingleton('catalog/product_action')->updateAttributes

This should be very fast.

Any ideas what's going wrong?

1 Answer 1

0

it may be issue with array();

first params must be a one dimensional array.

$foundProductID is integer value then it is one product id then it is ok array($foundProductID)

or ($foundProductID itself a array then it not ok

$foundProductID

it may like $foundProductID=array();

    Mage::getSingleton('catalog/product_action')->updateAttributes($foundProductID), 

array('name' => $language['name'], 'short_description' => $language['shortDescription'],

'description' => $language['desciption'], 'meta_description' => $language['metaDescription'], 'meta_keyword' => $language['metaKeyword'], 'meta_title' => $language['title']), $storeID);
2
  • $foundProductID = Mage::getModel('catalog/product')->getResource()->getIdBySku($sku); So it seems to be correct. Aug 20, 2014 at 17:20
  • yes..it right... array is right
    – Amit Bera
    Aug 20, 2014 at 17:25

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