Page 1 of 1

[SOLVED] - Events - Get Product data in action method after add product event.

Posted: Wed Mar 18, 2020 8:37 pm
by Mohal
OpenCart version is 2.3.0.2

I have successfully created my first module. My module uses Events System to perform an action. So, I trigger an action when product is added & edited.

I used following line of code to add action to the event in my module's model file:

Code: Select all

$this->model_extension_event->addEvent('mu_doaction', 'admin/model/catalog/product/addProduct/after', 'extension/module/mu_doaction/addActionProductAdd', 1);
Is there any way to pass product data to my action method? I need name of the product that is added or edited, in my action method.

Thanks!

Re: Events - Get Product data in action method after add product event.

Posted: Wed Mar 18, 2020 8:47 pm
by straightlight
What you didn't provide was your entire event controller file codes. You could use the $args being passed as a reference in the parameter to use the data. Wiki: https://github.com/opencart/opencart/wiki/Events-System

Re: Events - Get Product data in action method after add product event.

Posted: Thu Mar 19, 2020 8:33 pm
by Mohal
straightlight wrote:
Wed Mar 18, 2020 8:47 pm
What you didn't provide was your entire event controller file codes. You could use the $args being passed as a reference in the parameter to use the data. Wiki: https://github.com/opencart/opencart/wiki/Events-System
Thanks for the help. I solved the issue with $args.

Re: [SOLVED] - Events - Get Product data in action method after add product event.

Posted: Thu Mar 19, 2020 10:55 pm
by straightlight
Great. Now, you know how easy it is to use and handle events on your store. :)