Post by KillerDuck » Sun Jun 12, 2016 3:26 am

Hey All,

I've started creating my first module and wanted to know if it's possible to call information from other controllers/models than the one being worked on.

For example, displaying a list of manufacturers. I was going to create a model/controller/, call up manufacturers from db, assign to an array, echo output.

Can I include product/manufacturers model to get information?

(a working example would be appreciated)
Thanks

Newbie

Posts

Joined
Sun Jun 12, 2016 3:20 am

Post by fido-x » Sun Jun 12, 2016 11:20 am

KillerDuck wrote:Can I include product/manufacturers model to get information?
The manufacture model can be loaded with:

Code: Select all

$this->load->model('catalog/manufacturer');
Once the model is loaded, you can access any function from the model. For example, to get a list of manufacturers, you would use:

Code: Select all

$manufacturers = $this->model_catalog_manufacturer->getManufacturers();
This would load all manufacturers into an array called $manufacturers. You can then manipulate the data how you want.

Image
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool

If you're not living on the edge ... you're taking up too much space!


User avatar
Expert Member

Posts

Joined
Sat Jun 28, 2008 1:09 am
Location - Tasmania, Australia

Post by KillerDuck » Thu Jun 23, 2016 4:41 pm

Thanks for the info, worked perfectly!

Finally getting to grips with it now so really appreciated, thanks :D

Newbie

Posts

Joined
Sun Jun 12, 2016 3:20 am
Who is online

Users browsing this forum: No registered users and 9 guests