0

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?!

0

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.

  • I changed the capitalization as recommended up above, and the issue persists. I'm going to reiterate, this exact code is working in a Vagrant instance of magento but stops working in production. – Drew Peterson Dec 7 '16 at 22:02
  • I think that we understand that part of it. Different systems respond differently to capitalization. What else is different between these systems? Is the local.xml exactly the same between systems? (I'm thinking about differences in cache storage.) – Tyler V. Dec 8 '16 at 5:30
  • The files are exact copies. The OS is Ubuntu 14. Packages are completely the same. Both environments are completely up to date. I even spun up a new environment manually (virtual box) and ran into the same issue. This code only works in Vagrant. It's so baffling to me. – Drew Peterson Dec 8 '16 at 14:17
0

Try this

<observers> <company_collectbilltocode> <class>Company_collectBillToCode_Model_Observer</class> <method>captureBillTo</method> <company_collectbilltocode> </observers>
  • Did not resolve. I have other modules with the same lowercase structure that function without issue. I did try what you suggested though. – Drew Peterson Dec 7 '16 at 19:57
  • Also, this did not resolve. – Drew Peterson Dec 7 '16 at 20:45
0

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.

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.