I need to display on the manufacturers page only the first 3 positions. How can they be limited? Now they are displayed in alphabetical order (according to the standard). I would be grateful for the help.
I need to display any 3 manufacturers on the product main page. I decided to do this with the help of a module that I made myself. The principle of operation of the module is simple - it completely copies the functionality of the manufacturer_list page, therefore, it displays on my homepage all manufacturers. An example of what now turns out here http://www.mactedesign.com/ (as you can see, they go in a row and there are a lot of them, and I need only 3).
The controller code of the manufacturers.php module:
<?php class ControllerModuleManufacturers extends Controller { public function index() { $this->load->language('product/manufacturer'); $data['heading_title'] = $this->language->get('heading_title'); $data['text_brands'] = $this->language->get('text_brands'); $data['text_index'] = $this->language->get('text_index'); $data['brands'] = array(); $this->load->model('catalog/manufacturer'); $results = $this->model_catalog_manufacturer->getManufacturersByOrder(); //echo "<pre>"; print_r($setting); $this->load->model('tool/image'); foreach ($results as $result) { if (is_numeric(utf8_substr($result['name'], 0, 1))) { $key = '0 - 9'; } else { $key = utf8_substr(utf8_strtoupper($result['name']), 0, 1); } if (!isset($data['brands'][$key])) { $data['brands'][$key]['name'] = $key; } $data['brands'][$key]['manufacturer'][] = array( 'name' => $result['name'], 'image' => $this->model_tool_image->resize($result['image'], $this->config->get('config_image_thumb_width'), $this->config->get('config_image_thumb_height')), 'href' => $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $result['manufacturer_id']), 'limit' => 3 ); } if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/manufacturers.tpl')) { return $this->load->view($this->config->get('config_template') . '/template/module/manufacturers.tpl', $data); } else { return $this->load->view('default/template/module/manufacturers.tpl', $data); } } } Module output template code:
<h3>Top Catalogue</h3> <div id="manu" class="owl-carouse"> <?php if ($brands) { ?> <?php foreach ($brands as $brand) { ?> <?php if ($brand[ 'manufacturer']) { ?> <?php foreach ($brand[ 'manufacturer'] as $manufacturer) { ?> <div class="item text-center"> <a href="<?php echo $manufacturer['href']; ?>"><img src="<?php echo $manufacturer['image']; ?>" class="img-responsive"></a> <?php echo $manufacturer[ 'name']; ?> </div> <?php } ?> <?php } ?> <?php } ?> <?php } ?> </div>