0

I have an observer I want to run when the following event is triggered:<sales_quote_address_collect_totals_after>

I am basing my configuration on this: How to create an new observer on the event catalog_product_save_before

I have setup my config file as follows:

app/etc/modules/DBCustom_Sales.xml

<config>
    <modules>
        <DBCustom_Sales>
            <active>true</active>
            <codePool>local</codePool>
        </DBCustom_Sales>
    </modules>
</config>

app/code/local/DBCustom/Sales/etc/config.xml

 <config>
    <modules>
        <DBCustom_Sales>
            <version>0.1.0</version>
        </DBCustom_Sales>
    </modules>
    <global>
        <models>
            <sales>
                <rewrite>
                    <order_shipment>DBCustom_Sales_Model_Order_Shipment</order_shipment>
                    <order>DBCustom_Sales_Model_Order</order>
                </rewrite>
            </sales>
        </models>
    </global>
    <admin>
        <routers>
            <adminhtml>
                <args>
                    <modules>
                        <dbcustom_sales before="Mage_Adminhtml">DBCustom_Sales_Adminhtml</dbcustom_sales>
                    </modules>
                </args>
            </adminhtml>
        </routers>
    </admin>
    <events>
        <sales_quote_address_collect_totals_after>
            <observers>
                <dbcustom_sales>
                    <type>singleton</type>
                    <class>dbcustom_sales/observer</class>
                    <method>setShippingCost</method>
                </dbcustom_sales>
            </observers>
        </sales_quote_address_collect_totals_after>
    </events>
</config>

I have the path to the observer as follows: app/code/local/DBCustom/Sales/Model/Observer.php

class DBCustom_Sales_Model_Observer{
    public function setShippingCost($observer){
        $test = '';

    }
}

I am using PHPStorm with breakpoints setup on the $test variable so if the observer is active, it should break at $test, but it currently does not break on $test. I have cleared the site cache multiple times, and have confirmed that the event is being triggered, but nothing happens here. Any help is appreciated.

  • Can you post the full app/code/local/DBCustom/Sales/etc/config.xml? – Christoph Farnleitner Nov 13 '18 at 21:21
  • Updated with full config.xml – Eric Brown Nov 13 '18 at 21:23
  • 1
    Thanks, it's late here but shouldn't there be something like this in your models' node as well? <dbcustom_sales> <class>DBCustom_Sales_Model</class> </dbcustom_sales>; also, <events> is supposed to be a child of <global>. – Christoph Farnleitner Nov 13 '18 at 21:26
  • Awesome, that did it. Thank you for your help. – Eric Brown Nov 13 '18 at 21:30
  • you're welcome :) – Christoph Farnleitner Nov 13 '18 at 21:33
0
<dbcustom_sales>
    <class>DBCustom_Sales_Model</class>
</dbcustom_sales>

is (was) missing in the <models> node.

Also, is supposed to be a child of .

Full config.xml might look like this:

<config>
    <modules>
        <DBCustom_Sales>
            <version>0.1.0</version>
        </DBCustom_Sales>
    </modules>
    <global>
        <models>
            <dbcustom_sales>
                <class>DBCustom_Sales_Model</class>
            </dbcustom_sales>
            <sales>
                <rewrite>
                    <order_shipment>DBCustom_Sales_Model_Order_Shipment</order_shipment>
                    <order>DBCustom_Sales_Model_Order</order>
                </rewrite>
            </sales>
        </models>
        <events>
            <sales_quote_address_collect_totals_after>
                <observers>
                    <dbcustom_sales>
                        <type>singleton</type>
                        <class>dbcustom_sales/observer</class>
                        <method>setShippingCost</method>
                    </dbcustom_sales>
                </observers>
            </sales_quote_address_collect_totals_after>
        </events>
    </global>
    <admin>
        <routers>
            <adminhtml>
                <args>
                    <modules>
                        <dbcustom_sales before="Mage_Adminhtml">DBCustom_Sales_Adminhtml</dbcustom_sales>
                    </modules>
                </args>
            </adminhtml>
        </routers>
    </admin>
</config>

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.