1

I have a custom module that initiates on sales_order_invoice_register.

    <events>
        <sales_order_invoice_register>
            <observers>
                <make_sap>
                    <type>singleton</type>
                    <class>make_sap/observer</class>
                    <method>orderExport</method>
                </make_sap>
            </observers>
        </sales_order_invoice_register>
    </events>

In my Observer.php I want to retrieve the value of a custom variable from Magento:

class Make_Sap_Model_Observer {

private $_wsdlUrl           =   Mage::getModel('core/variable')->loadByCode('jgc_wsdlUrl')->getValue('text');
private $_user          =   Mage::getModel('core/variable')->loadByCode('jgc_wsdlUser')->getValue('text');
private $_pass          =   Mage::getModel('core/variable')->loadByCode('jgc_wsdlUser')->getValue('text');

With this, I get a server error

1 Answer 1

2
private $_wsdlUrl           =   Mage::getModel('core/variable')->loadByCode('jgc_wsdlUrl')->getValue('text');

That's a syntax error. In PHP You can only initialize properties with static scalar values, not with complex expressions like this. You have to move the assignment either into the constructor of the observer, or into the actual observer method orderExport():

$this->_wsdUrl = Mage::getModel('core/variable')->loadByCode('jgc_wsdlUrl')->getValue('text');
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.