I'm working on an OpenCart project, that requires a lot of customization. for my project I have to change something in the cart library (system/library/cart.php).
I would have to call a custom function that's defined inside the product model (catalog/model/catalog/product.php).
In a controller, loading a Model and using its functions is easy:
$this->load->model("catalog/product");
$this->model_catalog_product->customFunction();
But how do you load a model outside a controller? You can't create a new instance of the model, I already tried that:
require_once("catalog/model/catalog/product.php");
$a_model = new ModelCatalogProduct();
This obviously doesn't work cause models weren't intended to be used in such a way.
I also tried to use the scope resolution operator ( ModelCatalogProduct::customFunction()) It doesn't work either.
I could pass all the required info as arguments, but I would rather use the model inside the cart library class, cause the changes would be global.
Is it even possible to load a model outside a controller in OpenCart?