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

Error on product’s price update
 
heathen
Sr. Member
 
Avatar
Total Posts:  100
Joined:  2009-04-07
 

Hi!

I have a strange error on price update.

I use the code:

$sku 'some_sku';
$price 123.45;

$product Mage::getModel('catalog/product');

$product->load($product->getIdBySku($sku));

$productNew->setPrice($price);
$productNew->save();

and get an exeption:

WarningInvalid argument supplied for foreach()  in <path_to_magento>/app/code/core/Mage/Eav/Model/Entity/Abstract.php on line 970
Trace
:
#0 <path_to_magento>/app/code/core/Mage/Eav/Model/Entity/Abstract.php(970): mageCoreErrorHandler(2, 'Invalid argumen...', '/private/usr/lo...', 970, Array)
#1 <path_to_magento>/app/code/core/Mage/Eav/Model/Entity/Abstract.php(925): Mage_Eav_Model_Entity_Abstract->_collectSaveData(Object(Mage_Catalog_Model_Product))
#2 <path_to_magento>/app/code/core/Mage/Core/Model/Abstract.php(251): Mage_Eav_Model_Entity_Abstract->save(Object(Mage_Catalog_Model_Product))
#3 <path_to_magento>/app/code/local/ITGorod/Motorzona/Model/Category.php(87): Mage_Core_Model_Abstract->save()
#4 <path_to_magento>/app/code/local/ITGorod/Motorzona/Model/Category.php(54): ITGorod_Motorzona_Model_Category->_setProducts(Array)
#5 <path_to_magento>/app/code/local/ITGorod/Motorzona/Model/Category.php(17): ITGorod_Motorzona_Model_Category->_getMotorzonaData('http://www.moto...')
#6 <path_to_magento>/app/code/local/ITGorod/Motorzona/Block/Category/View.php(8): ITGorod_Motorzona_Model_Category->prepareMotorzonaData()
#7 <path_to_magento>/app/code/core/Mage/Core/Block/Abstract.php(199): ITGorod_Motorzona_Block_Category_View->_prepareLayout()
#8 <path_to_magento>/app/code/core/Mage/Core/Model/Layout.php(445): Mage_Core_Block_Abstract->setLayout(Object(Mage_Core_Model_Layout))
#9 <path_to_magento>/app/code/core/Mage/Core/Model/Layout.php(229): Mage_Core_Model_Layout->addBlock('ITGorod_Motorzo...', 'category.produc...')
#10 <path_to_magento>/app/code/core/Mage/Core/Model/Layout.php(195): Mage_Core_Model_Layout->_generateBlock(Object(Mage_Core_Model_Layout_Element), Object(Mage_Core_Model_Layout_Element))
#11 <path_to_magento>/app/code/core/Mage/Core/Model/Layout.php(200): Mage_Core_Model_Layout->generateBlocks(Object(Mage_Core_Model_Layout_Element))
#12 <path_to_magento>/app/code/core/Mage/Core/Controller/Varien/Action.php(303): Mage_Core_Model_Layout->generateBlocks()
#13 <path_to_magento>/app/code/core/Mage/Catalog/controllers/CategoryController.php(101): Mage_Core_Controller_Varien_Action->generateLayoutBlocks()
#14 <path_to_magento>/app/code/core/Mage/Core/Controller/Varien/Action.php(376): Mage_Catalog_CategoryController->viewAction()
#15 <path_to_magento>/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(248): Mage_Core_Controller_Varien_Action->dispatch('view')
#16 <path_to_magento>/app/code/core/Mage/Core/Controller/Varien/Front.php(158): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#17 <path_to_magento>/app/Mage.php(459): Mage_Core_Controller_Varien_Front->dispatch()
#18 <path_to_magento>/index.php(65): Mage::run()
#19 {main}

What can I do with that?

 
Magento Community Magento Community
Magento Community
Magento Community
 
deedev
Jr. Member
 
Total Posts:  26
Joined:  2008-11-10
Montpellier
 

Hello,

try to add this line

Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top