AbanteCart Community
AbanteCart Development => API Development => Topic started by: huyhoang08 on March 15, 2016, 03:54:22 AM
-
i need to load model from other controller? help me?
-
Hi, I suggest you to read abantecart core codes both on storefront and admin so you can understand better about calling model etc. You can just use $this->load->model('existing_model'); from your controller.
-
i need to load model from other controller? help me?
To load model, you need to include it with below code and you can access methods:
See examples with 'sale/order' model in admin.
$this->loadModel('sale/order');
$orders = $this->model_sale_order->getOrders();
or with generic loader class
$this->load->model('sale/order');
$orders = $this->model_sale_order->getOrders();
-
First sory for my english skill.
I cleared about that, But for example:
i have 2 extension activated:
Sory, i mean from one extension i able to load a model belong to other extension?
-
You can do that, it's the same as what abantecart says. As long as you know which model that you want to access and use.
-
thank you, i sloved my issue, i think PHP model file should have only _ in file name
-
Hi,
I know this thread is a bit old, but I had a similar question for an extension I am working on.
I am trying to call a function from a different model to delete a product, but as soon as I use that syntax, everything breaks.
$this->load->model('catolog/product');
$this->model_catalog_product->deleteProduct((int)$id);
Error:
load error: AbanteCart core v.1.2.13 Error: Could not load model catolog/product from /home/####/####.com/####/extensions/####/admin/model/catalog/####.php on line 47 in <b>/home/####/####.com/####/core/engine/loader.php</b> on line <b>120</b>
Am I doing something wrong?
-
try this:
$that = $this->baseObject;
$that->load->model(....);
$that->model_......
-
try this:
$that = $this->baseObject;
$that->load->model(....);
$that->model_......
If you do this inside of the ext. hook file, it is correct
-
Now I am receiving different errors.
AbanteCart core v.1.2.13 Call to a member function model() on null in ######
Does anyone know of any useful tutorials for making extensions in Abantecart? The developer's guide provided is very limited.
-
Hi,
seems you have a typo here:
$this->load->model('catolog/product'); should be $this->load->model('catalog/product');
And are you calling the model from extension hook file or not?
-
I am not calling from a hook file, but the typo was the issue.
Thank you very much, after looking at the same code for hours I just couldn't see it.
-
You're welcome