Question

I made module to add 100 USD to all products price using module, but it does not work as expected. Need help to fix it.

Below is my event observer xml code:

<catalog_product_collection_load_after>
            <observers>
                <setname>
                    <type>model</type>
                    <class>Mdoule_Customgroup_Model_Observer</class>
                    <method>modifyall</method>
                </setname>
            </observers>
</catalog_product_collection_load_after>

and modifyall function is as below:

    public function modifyall(Varien_Event_Observer $observer) {
        $products = $observer->getCollection();
        foreach( $products as $product )
        {
            $originalprice = $product->getPrice();
            $customprice = $originalprice+ 100;
            $product->setPrice($customprice);
            $product->setCustomPrice($customprice);
            $product->setOriginalCustomPrice($customprice);
        }
   }

that works fine but i get price like below:

$1,450 $1,550

Was it helpful?

Solution

I have tested your code and modified it use below :

  public function modifyall(Varien_Event_Observer $observer) {
        $products = $observer->getCollection();
        foreach( $products as $product )
        {
            $originalprice = $product->getPrice();
            $customprice = $originalprice+ 100;
            $product->setPrice($customprice);
            $product->setCustomPrice($customprice);
            $product->setOriginalCustomPrice($customprice);
            $product->setFinalPrice($customprice);
        }
   }
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top