i have written modules that changes price of all products on product details page, including related showing on bottom .
what modules does here i am passing some product id in get parameter and adding price of it in all products on product detail page
Issue facing My module works fine for simple products issue comes $_GET['id'] is id of configurable product.
Error i get Fatal error: Maximum function nesting level of '500' reached, aborting! in PATH\lib\Zend\Db\Adapter\Pdo\Mysql.php on line 117
after debug found calling $pricetoadd = Mage::getModel('catalog/product')->setSkipCustomPriceObserver(true)->load($_GET['id']); causes error when $_GET['id'] is configurable products id why so ?
config.xml
<catalog_product_collection_load_after>
<observers>
<setname>
<type>model</type>
<class>Mour_Customgroup_Model_Observer</class>
<method>modifyallname</method>
</setname>
</observers>
</catalog_product_collection_load_after>
Observer.php
public function modifyallname(Varien_Event_Observer $observer) {
$products = $observer->getCollection();
foreach( $products as $product )
{
if($_GET['id']==""){
break;
}
$pricetoadd = Mage::getModel('catalog/product')->setSkipCustomPriceObserver(true)->load($_GET['id']);
//this will set a flag that will be handled by the if statement above. If this flag is true your code will not be executed.
$originalprice = $product->getPrice();
$model = Mage::getModel('eav/entity_attribute_set');
$currentattribid = (int)$product->getAttributeSetId();
$customprice = $originalprice+$pricetoadd->getPrice();
if ($customprice > 0) {
$product->setFinalPrice($customprice);
$product->setMinimalPrice($customprice);
}
}
}