Notes
How to get and show Manufacturers in OpenCart
loading OpenCart manufacturers in the header controller with getManufacturers() and showing their logos in header.tpl
OpenCart
Add the following code to catalog/controller/common/header.php
1// MANUFACTURERS
2$this->load->model('catalog/manufacturer');
3
4$data['manufacturers'] = $this->model_catalog_manufacturer->getManufacturers(0);
Now in your catalog/view/common/header.tpl, you can use a foreach loop to get all the manufacturers out of the array
1<?php if ($manufacturers) {
2 foreach($manufacturers as $manufacturer) { ?>
3 <a href="index.php?route=product/manufacturer/info&manufacturer_id=<?php echo $manufacturer['manufacturer_id']; ?>"><img src="<?php echo $manufacturer['image']; ?>" alt="<?php echo $manufacturer['name']; ?>" /></a>
4 <?php } ?>
5<?php } ?>
The getManufacturers() method provides an array of arrays, with the following details
10 =>
2array (
3 'manufacturer_id' => '8',
4 'name' => 'Apple',
5 'image' => 'catalog/demo/apple_logo.jpg',
6 'sort_order' => '0',
7 'store_id' => '0',
8),
It then gets passed along to the template as part of $data