2

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

  • can you tell me what is display current price? – Ajay Patel Mar 12 '16 at 11:43
  • it show 1550 with line over and also 1450 i just want 1550 – mdeveloper Mar 12 '16 at 11:52
  • i think you print both price $originalprice as well as $customprice on phtml file. – Ajay Patel Mar 12 '16 at 11:54
  • You want to show special and regular price ? – Arunendra Mar 14 '16 at 6:59
4

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.