apologies in advance - I'm pretty new to Magento development but not to web dev in general. I have a strong background in OOP and MVC PHP frameworks but in all honesty I'm struggling to pick up Magento.

I have a custom module I've created in /local which has an observer running after an order is created. This is working fine and logging correctly. Once an order is created and one of the items matches a certain criteria I need it to create a 'job' automatically and render a barcode of the jobId to a static image.

I have all three elements (observer a new order, create a job, create a barcode) of the process working fine via their own controller actions, instigated from the admin area on an order but I can't figure out how to hook it altogether as part of the observer so it happens automatically on order creation.

How can I (or rather can I) use existing controller actions, saveJobAction for example, from within another module's observer? If so, what's the correct syntax for the call?

It needs to happen behind the scenes so I'm guessing a redirect or _forward wouldn't work in this instance?


First of all you have to move all your code from controller into Models. Having this, you will be triggering models in the controller actions.

If I understood you correctly, you have 1 module with all 3 elements, is this correct?

Observer class has to be your entry point where all 3 elements of your process will be used. This is important to build transaction operation because it might be a problem in case something would not be created. Having 3 different observers which listen 3 controller actions, I will not recommend this approach.

The observer should listen Shipment event - when shipment for order is created, then barcode has to be created.

Hope this helps.

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.