Skip to main content
full config.xml code
Source Link
Charlie
  • 3.1k
  • 7
  • 38
  • 63
    <?xml version="1.0"?>
<config>
    <modules>
        <Npm_Commission>
            <version>0.1.0</version>
        </Npm_Commission>
    </modules>
    <global>
        <events>
            <sales_order_place_after>
                <observers>
                    <npm_commission>
                        <type>singleton</type>
                        <class>Npm_Commission_Model_Observer</class>
                        <method>saveorder<<method>calculate_commission</method>
                    </npm_commission>
                </observers>
            </sales_order_place_after>
        </events>
....        <resources>
            <commission_setup>
                <setup>
                    <module>Npm_Commission</module>
                </setup>
                <connection>
                    <use>core_setup</use>
                </connection>
            </commission_setup>
            <commission_write>
                <connection>
                    <use>core_write</use>
                </connection>
            </commission_write>
            <commission_read>
                <connection>
                    <use>core_read</use>
                </connection>
            </commission_read>
        </resources>
        <models>
            <commission>
                <class>Npm_Commission_Model</class>
                <resourceModel>commission_mysql4</resourceModel>
            </commission>
            <commission_mysql4>
                <class>Npm_Commission_Model_Mysql4</class>
                <entities>
                    <commission>
                        <table>commission</table>
                    </commission>
                </entities>
            </commission_mysql4>
        </models>
    </global>
</config>
<?xml version="1.0"?>
<config>
    <modules>
        <Npm_Commission>
            <version>0.1.0</version>
        </Npm_Commission>
    </modules>
    <global>
        <events>
            <sales_order_place_after>
                <observers>
                    <npm_commission>
                        <type>singleton</type>
                        <class>Npm_Commission_Model_Observer</class>
                        <method>saveorder</method>
                    </npm_commission>
                </observers>
            </sales_order_place_after>
        </events>
....
    <?xml version="1.0"?>
<config>
    <modules>
        <Npm_Commission>
            <version>0.1.0</version>
        </Npm_Commission>
    </modules>
    <global>
        <events>
            <sales_order_place_after>
                <observers>
                    <npm_commission>
                        <type>singleton</type>
                        <class>Npm_Commission_Model_Observer</class>
                        <method>calculate_commission</method>
                    </npm_commission>
                </observers>
            </sales_order_place_after>
        </events>
        <resources>
            <commission_setup>
                <setup>
                    <module>Npm_Commission</module>
                </setup>
                <connection>
                    <use>core_setup</use>
                </connection>
            </commission_setup>
            <commission_write>
                <connection>
                    <use>core_write</use>
                </connection>
            </commission_write>
            <commission_read>
                <connection>
                    <use>core_read</use>
                </connection>
            </commission_read>
        </resources>
        <models>
            <commission>
                <class>Npm_Commission_Model</class>
                <resourceModel>commission_mysql4</resourceModel>
            </commission>
            <commission_mysql4>
                <class>Npm_Commission_Model_Mysql4</class>
                <entities>
                    <commission>
                        <table>commission</table>
                    </commission>
                </entities>
            </commission_mysql4>
        </models>
    </global>
</config>
Source Link
Charlie
  • 3.1k
  • 7
  • 38
  • 63

observer method sales_order_place_after not executing

I am using magento 1.8. I have requirement that need to save the order details in separate custom table. for this I need to execute saveorder method using observer event sales_order_place_after But when I am clicking place order, My observer function is not executing,

My config.xml file content

<?xml version="1.0"?>
<config>
    <modules>
        <Npm_Commission>
            <version>0.1.0</version>
        </Npm_Commission>
    </modules>
    <global>
        <events>
            <sales_order_place_after>
                <observers>
                    <npm_commission>
                        <type>singleton</type>
                        <class>Npm_Commission_Model_Observer</class>
                        <method>saveorder</method>
                    </npm_commission>
                </observers>
            </sales_order_place_after>
        </events>
....

my observer method

<?php
class Npm_Commission_Model_Observer extends Varien_Event_Observer
{
    public function saveorder($observer)
    {
        die('sales_order_place_after');
        $params = Mage::app()->getFrontController()->getRequest()->getParams();
        echo "<pre>";print_r($params);die();
    }

If this information is not enough, add in comment for other part of code. And suggest any other idea for this issue, Or my faults in this code.

Thank you friends:)