0

I am new in magento. I created a custom observer to trigger on the event sales_order_place_before, but its not working.

Here's my code: app/etc/modules/CustomPriceUpdate_Checkout.xml

<?xml version="1.0"?>
<config>
    <modules>
        <CustomPriceUpdate_Checkout>
            <codePool>local</codePool>
            <active>true</active>
            <depends>
                <Mage_Catalog />
            </depends>
        </CustomPriceUpdate_Checkout>
    </modules>
</config>

app/code/local/CustomPriceUpdate/Checkout/etc/config.xml

<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
    <CustomPriceUpdate_Checkout>
        <version>0.0.1</version>
    </CustomPriceUpdate_Checkout>
</modules>
<global>
    <models>
        <myCustomPriceUpdate_Checkout>
            <class>CustomCheckout_Event_Model</class>
        </myCustomPriceUpdate_Checkout>
    </models>
    <events>
        <sales_order_place_before>
            <observers>
                <modify_product_price>
                    <type>singleton</type>
                    <class>myCustomPriceUpdate_Checkout/observer</class>
                    <method>update_price</method>
                </modify_product_price>
            </observers>
        </sales_order_place_before>
    </events>
</global>
</config>

app/code/local/CustomPriceUpdate/Checkout/Model/Observer.php

<?php
class CustomCheckout_Event_Model_Observer{

  public function update_price($observer){
    Mage::log("Order is placed");
  }
}

When I check the system.log file, I am seeing following error:

Warning: include(CustomCheckout/Event/Model/Observer.php): failed to open stream: No such file or directory in /var/www/html/lib/Va$

Warning: include(): Failed opening 'CustomCheckout/Event/Model/Observer.php' for inclusion (include_path='/var/www/html/app/code/loc$

Can anyone please suggest, what's wrong in the code ?

1

Change this

    <myCustomPriceUpdate_Checkout>
        <class>CustomCheckout_Event_Model</class>
    </myCustomPriceUpdate_Checkout>

To this

    <myCustomPriceUpdate_Checkout>
        <class>CustomPriceUpdate_Checkout_Model</class>
    </myCustomPriceUpdate_Checkout>
1

Adding to @Marius answer change class name in your observer as shown below

<?php
class CustomPriceUpdate_Event_Model_Observer{

    public function update_price($observer){
       Mage::log("Order is placed");
 }
}
  • hi murtuza, Please open once this url. and place order with cod. place order is not working. depoto.com its urgent to me. sorry for asking here – Teja Bhagavan Kollepara Jan 12 '17 at 12:21
  • @TejabhagavanKollepara this URL is blocked in my firewall I will check after 5 hours – Murtuza Zabuawala Jan 12 '17 at 12:27
  • ok but please reply me thank you – Teja Bhagavan Kollepara Jan 12 '17 at 12:28
  • @TejabhagavanKollepara I can able to place order as a guest user and complete checkout process – Murtuza Zabuawala Jan 12 '17 at 17:37
  • Ok.. Please create account and check with registered uset details Please... Because i tried with my login credentials – Teja Bhagavan Kollepara Jan 13 '17 at 11:01
0

You model class reference is wrong here. You used CustomCheckout_Event_Model in your config.xml file. Instead of that, you need to use CustomCheckout_Checkout_Model.

So you need to change model definition like :

<myCustomPriceUpdate_Checkout>
    <class>CustomPriceUpdate_Checkout_Model</class>
</myCustomPriceUpdate_Checkout>

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.