Reputation: 2790
I'm doing a module to Magento my module have the same functions of Crosssell native function from magento. I have this product grid and the user select some checkboxes to associate this products to the main product. All ok.
But, I've create a custom attribute to save the ID's of this products and make a Observer to 'catalog_product_save_after' event:
<events>
<catalog_product_save_after>
<observers>
<brindeproduto_save_product_data>
<type>singleton</type>
<class>brindeproduto/observer</class>
<method>saveProductTabData</method>
</brindeproduto_save_product_data>
</observers>
</catalog_product_save_after>
</events>
On my saveProductTabData I load the main product by the ID on Request, and put the IDS of the selecte products on my custom attribute like these "1,2,3,4,5,6".
Ok, but when I do $product->save(); I got infinite load on my browser, without any error or exeption. The code on observer are simple.
$product = Mage::getModel('catalog/product')->load($product_id);
//some logical Specific information that is not in question now.
$product->save();
Nothing more.
I've tryed debug the save function and get some intriguing result. On Mage_Core_Model_Abstract function save(), I put some die on parts of code, and get all of then. this code it's part of function save line 330 on Magento 1.5 Community.
if ($dataCommited) {
$this->_afterSaveCommit();
}
return $this;
It's the last line on function. I put die before return.
if ($dataCommited) {
$this->_afterSaveCommit();
}
die('test');
return $this;
I've got the die. But nothing more before return. Some body have ideia of what's happen?? Lost by 5 hours on that. Any help will be mutch appreciated.
Upvotes: 0
Views: 292
Reputation: 17656
You should NOT be doing any save in your observer (*_save_after).
This will cause a never ending loop
Upvotes: 2