Page 1 of 1

[SOLVED] About 4.0.2.3 event hooks question

Posted: Wed Jun 19, 2024 7:04 pm
by D3MO
Started remaking ocmod modules to event based . and there is so many not clear things:)) for example event trigger it is working all ok

Code: Select all

$this->model_setting_event->addEvent(['code'=>'module_user_group_price', 'description' => '', 'trigger' => 'catalog/model/catalog/product/getProduct/after', 'action' => 'extension/user_groups_pricing_rules/module/user_group_price.SetPrice', 'status'=>1, 'sort_order'=>1]);

and opencart 4.0.2.3 has new folder EXTENSION in root folder and some stock modules preinstalled, so trying to add trigger to a module function : extension/opencart/total/sub_total/getTotal/after and it doesnt ttrigger. also events is a pain to modify returned data from library classes like tax.

Code: Select all

$this->model_setting_event->addEvent(['code'=>'module_user_group_price', 'description' => '', 'trigger' => 'extension/opencart/total/sub_total/getTotal/after', 'action' => 'extension/user_groups_pricing_rules/module/user_group_price.SetSubtotal', 'status'=>1, 'sort_order'=>1]);
maybe someone could share a light here why "'catalog/model/catalog/product/getProduct/after" do work. and "extension/opencart/total/sub_total/getTotal/after' do not works

Re: About 4.0.2.3 event hooks question

Posted: Wed Jun 19, 2024 7:16 pm
by D3MO
found myself. you need to trigger as it would be like in old structure

catalog/model/extension/opencart/total/sub_total/getTotal/after

Now need to find out how to override library class variables.

Re: About 4.0.2.3 event hooks question

Posted: Wed Jun 19, 2024 10:28 pm
by paulfeakins
D3MO wrote:
Wed Jun 19, 2024 7:16 pm
found myself. you need to trigger as it would be like in old structure

catalog/model/extension/opencart/total/sub_total/getTotal/after

Now need to find out how to override library class variables.
What do you think of developing with Events so far vs. OCMOD?

Re: About 4.0.2.3 event hooks question

Posted: Thu Jun 20, 2024 2:30 pm
by D3MO
paulfeakins wrote:
Wed Jun 19, 2024 10:28 pm
D3MO wrote:
Wed Jun 19, 2024 7:16 pm
found myself. you need to trigger as it would be like in old structure

catalog/model/extension/opencart/total/sub_total/getTotal/after

Now need to find out how to override library class variables.
What do you think of developing with Events so far vs. OCMOD?
Well since we used ocmod for decade:))of course we are used to it:) but time do not stand in one place , and everything evolves. With events some features are easier to make than with modules and hooking system is perfect if you want perform some actions before or after some functions, instead of changing the code itself . But ocmod were usefull also if you require to alter very litle code instead of making an event. in my opinion ocmod should be integrated in opencart and user itself could decide to use ocmod module or no. there could be in marketplace selection what type of module event based or xml changes based. because the very same way and events can overlap with each other the very same like ocmods. but there is as is