0

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);
            }

        }
   }
3
  • have you posted $_GET['id'] via form or get current product?
    – Abdul
    Commented Jun 16, 2016 at 11:40
  • in url like ?id=11
    – mdeveloper
    Commented Jun 16, 2016 at 11:44
  • @Abdul can you help me with issue
    – mdeveloper
    Commented Jun 17, 2016 at 6:38

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.