title: Programatically update product price in Magento - Invalid argument supplied for foreach()
body: <p>I am trying to programatically update a product's price within a custom module. This is my code:</p>
  
  <pre><code>Mage::setIsDeveloperMode(true); // for debug only
  try
  {
      $product = Mage::getModel('catalog/product')-&gt;load($productId);
      $product-&gt;setPrice($newPrice);
      $product-&gt;save();
  }
  catch (Exception $ex)
  {
      echo "Error: ". $ex-&gt;getMessage();
  }
  </code></pre>
  
  <p>When this code executes, I get the following exception:</p>
  
  <blockquote>
    <p>Warning: Invalid argument supplied for foreach()  in
    /home/www-data/public_html/app/code/core/Mage/Eav/Model/Entity/Abstract.php
    on line 1180</p>
  </blockquote>
  
  <p>In the <code>system.log</code> file, I see allot of these entries:</p>
  
  <blockquote>
    <p>2016-03-17T18:01:06+00:00 ERR (3): Warning: Invalid argument supplied
    for foreach()  in
    /home/www-data/public_html/app/code/core/Mage/Eav/Model/Entity/Abstract.php
    on line 1180 2016-03-17T18:01:06+00:00 ERR (3): Recoverable Error:
    Argument 3 passed to
    Mage_Catalog_Model_Resource_Abstract::_canUpdateAttribute() must be of
    the type array, null given, called in
    /home/www-data/public_html/app/code/core/Mage/Eav/Model/Entity/Abstract.php
    on line 1225 and defined  in
    /home/www-data/public_html/app/code/core/Mage/Catalog/Model/Resource/Abstract.php
    on line 543 2016-03-17T18:01:06+00:00 ERR (3): Recoverable Error:
    Argument 3 passed to
    Mage_Eav_Model_Entity_Abstract::_canUpdateAttribute() must be of the
    type array, null given, called in
    /home/www-data/public_html/app/code/core/Mage/Catalog/Model/Resource/Abstract.php
    on line 545 and defined  in
    /home/www-data/public_html/app/code/core/Mage/Eav/Model/Entity/Abstract.php
    on line 1254 2016-03-17T18:01:06+00:00 ERR (3): Warning:
    array_key_exists() expects parameter 2 to be array, null given  in
    /home/www-data/public_html/app/code/core/Mage/Eav/Model/Entity/Abstract.php
    on line 1256</p>
  </blockquote>
  
  <p>Any idea what might be causing this? The same code on my dev magento setup works, but in production magento, this error started to appear, so I am a little confused.</p>