Question

I can't think of the reason why this is happening. I have a custom module in a vagrant box, which works perfectly. When I migrate my code/database to an actual server, the magento event does not seem to fire. I put a tracer on dispatchEvent in Mage.php to prove that the event is firing, which it is. The custom module looking for that event doesn't seem to fire.

My code is as follows: /app/code/local/Company/collectBillToCode/Model/Observer.php

<?php
//fires after billing info is saved
class Company_collectBillToCode_Model_Observer{
    public function captureBillTo(Varien_Event_Observer $observer){
        $customerGroupId=Mage::getSingleton('customer/session')->getCustomerGroupId();
        $customerGroupName=Mage::getModel('customer/group')->load($customerGroupId)->getCustomerGroupCode();

        //confirm this is an international order, and then collect the information as needed
        if($customerGroupName=='Internal_International'){
            $billingInfo=Mage::app()->getFrontController()->getRequest()->getParams()['billing'];
            //save $billingInfo['bill-to'] to session so that it can be retreived by all components

            Mage::getSingleton('core/session')->setBillToCode($billingInfo['bill-to']);
        }
    }
}
?>

Config.xml: /app/code/local/Company/collectBillToCode/etc/config.xml

<?xml version="1.0" encoding="UTF-8"?>
<config>
   <modules>
        <Company_collectBillToCode>
            <version>0.0.1</version>
        <Company_collectBillToCode>
   </modules>
   <global>
        <models>
            <company_collectbilltocode>
                <class>Company_collectBillToCode_Model</class>
            <company_collectbilltocode>
        </models>
        <events>
            <controller_action_predispatch_checkout_onepage_saveBilling>
                <observers>
                    <company_collectbilltocode>
                        <class>company_collectbilltocode/observer</class>
                        <method>captureBillTo</method>
                        <type>singleton</type>
                    <company_collectbilltocode>
                </observers>
            </controller_action_predispatch_checkout_onepage_saveBilling>
        </events>
   </global>
</config>

And the module: /app/etc/modules/Company_collectBillToCode.xml

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <modules>
        <Company_collectBillToCode>
            <active>true</active>
            <codePool>local</codePool>
        </Company_collectBillToCode>
    </modules>
</config>

I have cleared caches, sessions, recompiled, reindexed permissions are set to www-data with 775. Instance is completely patched. My other custom module looking for a similar event controller_action_postdispatch_checkout_onepage_saveBilling DOES fire. I'm stumped. -_-

To be clear, this works 100% in my vagrant instance of magento, when I copy the code from git it stops working. What step is missing?!

Était-ce utile?

La solution

I agree with Krishnan that this is likely related to capitalization.

Some of what you're doing here doesn't match Magento's standard practices. For instance, Company_collectBillToCode_Model should probably be Company_CollectBillToCode_Model and Company/collectBillToCode/Model/Observer.php should be Company/CollectBillToCode/Model/Observer.php, etc. I would recommend capitalizing Collect in all cases where there are any capitals.

You might also try removing all of the capitalizations after Collect and going from there.

Autres conseils

Try this

<observers> <company_collectbilltocode> <class>Company_collectBillToCode_Model_Observer</class> <method>captureBillTo</method> <company_collectbilltocode> </observers>

So after all of that work. Here's what happened:

Git, doesn't recognize file/folder name changes if the change is capitalization. I pushed my changes into git, not realizing that the code that I modified did actually commit to the git repo.

When I changed collectBillToCode to CollectBillToCode git didn't see the naming changes, it only saw the file changes.

My workaround was, remove the directory, commit to git, push to git. Add the directory again, commit to git, push to git.

RESOLVED.

Licencié sous: CC-BY-SA avec attribution
Non affilié à magento.stackexchange
scroll top