Post by Mohal » Wed Mar 18, 2020 8:37 pm

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!

Newbie

Posts

Joined
Wed Jul 21, 2010 8:34 pm

Post by straightlight » 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

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by Mohal » Thu Mar 19, 2020 8:33 pm

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.

Newbie

Posts

Joined
Wed Jul 21, 2010 8:34 pm

Post by straightlight » Thu Mar 19, 2020 10:55 pm

Great. Now, you know how easy it is to use and handle events on your store. :)

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: No registered users and 38 guests