2

I'm working on refactoring a backend extension which uses the global Mage::registry('current_shipment') to retrieve the current shipment for printing. I'd like to change this line to something that doesn't use a global.

How would I go about retrieving the current shipment value without using the Mage registry?

  • It depends on the code of the extension. In the end you will either have to pass around the current shipment as parameter or set it as an attribute to an object that is known to all client classes which need access to it. – Fabian Schmengler Jun 29 '16 at 11:12
1

While I appreciate the sentiment of trying to not rely on globals Magento is FULL of them. If this is 3rd party code, or code that your team has written, I suggest using a controller to load the model, and set that model to the blocks or model where they're needed explicitly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy