I have a problem with methods which are being called from another method in the same model not firing events registered for them.
Example:
I have registered an event for the catalog/model/chekcout/addOrderHistory() method, which works as expected.
However, I have created another method in the same model which calls addOrderHistory:
Code: Select all
public function verifyOrder($order_id) {
$this->addOrderHistory($order_id, 29);
}
I digged a little further and decided the cause was not binding the closure in the model proxy.
So, I modified the Loader class as follows:
Code: Select all
$proxy = new \Opencart\System\Engine\Proxy();
foreach (get_class_methods($model) as $method) {
if ((substr($method, 0, 2) != '__') && is_callable($class, $method)) {
$closure = function (mixed &...$args) use ($route, $model, $method): mixed {
...
};
$closure = $closure->bindTo($proxy, $proxy);
$proxy->{$method} = $closure;
}
}
$this->registry->set($key, $proxy);
Any help would be appreciated.
Regards,
Alex