Magento app/code/core/Mage/Eav/Model/Entity/Abstract.php on line 1180 error

You try to save a product and you get this error : Invalid argument supplied for foreach().
This was unexpected and you don’t understand why.

The problem is, that you are not allowed to save products from the frontend.
The origData property is not filled

public function setOrigData($key=null, $data=null)
{
    if (Mage::app()->getStore()->isAdmin()) {
        return parent::setOrigData($key, $data);
    }

    return $this;
}

So when you try to save the product, this error is raised.

What to do when you encounter this error ?

A quick fix is to add this before saving, on your controller for example.

Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);

A proper solution is to extend Mage_Catalog_Model_Product and replace setOrigData method

public function setOrigData($key = null, $data = null)
{
    if (is_null($key)) {
        $this->_origData = $this->_data;
    } else {
        $this->_origData[$key] = $data;
    }
    return $this;
}