Thursday 15 March 2012

php - OpenCart - Displaying Manufacturer logos in Category page -


OK, so I want to display the creator logo of each category. The manufacturer must be related to the logo category, i.e. the mobile phone range should be displayed only to the manufacturer logo which belongs to the category. Mobile phones such as Microsoft or Sony's logo should not be displayed here (Mobile Phone Category) Instead, instead it should be displayed in the Gaming Console category.

Catalog / Controller / Product / Category.php

  $ this-> Load-> Model ('list / maker'); $ This- & gt; Data ['makers'] = array (); $ Result = $ this- & gt; Model_list_manufacturer-> Union producer (); Foreach ($ result as result of $) {$ this- & gt; Data ['makers] [] = resize ($ result [' image '], 80,80),' name '= & (size =' manufacturer_image '= & gt; $ this-> model_tool_image- & gt; Gt; $ result ['name'], 'href' => $ this-> url- & gt; link ('product / manufacturer / information', 'manufacturer_id ='. $ Result ['manufacturer_id'] )); }   

category.tpl

  & amp; Php foreach (as Manufacturer $ manufacturer) {? & Gt; & Lt; img src = "& lt ;? Php $ manufacturer [ 'Nirmata_aij'] ;? & Gt; / & Gt; & Lt ;? Php}? & Gt;   

Currently it all In the categories, all the manufacturers show the logo.

OpenCart's stock maker model does not offer this kind of functionality, so you'll need to create a new method. /catalog/model/product/manufactuer.php

  public function getManufacturersByCatgoryId ($ category_id) {$ query = $ Select this- & gt; db- & gt; Query (ON (p.product_id = p2s "Meter) . DB_PREFIX ". The *." Product_to_category P2C LEFT JOIN ". DB_PREFIX." Products Join Left (p2c.product_id = p.product_id) P ". DB_PREFIX." Product_to_store p2s .product_id) LEFT JOIN ". DB_PREFIX. "Manufacturers join left (m.manufacturer_id = p.manufacturer_id) m". DB_PREFIX. "manufacturer_to_store m2s at (m2s.manufacturer_id = p.manufacturer_id) Where p2c.category_id = ''. (int) $ category_id" 'and m2s .store_id = "(int) $ this->. Config- & gt; Get ( 'config_store_id') " 'and p.status = 1 and p2s.store_id =' '.. (Int) $ this- & gt; config- & Get gt; (' config_store_id ')."' By GroupM . Producer 'id' '); Refund $ query-> Rows; }   

You can get it done by doing it in your controller and you can use that code, which you have already passed to see it:

  $ this-> Load-> Model ('product manufactuer /'); $ Manufacturers = $ this- & gt; Model_product_manager- & gt; GetManufacturersByCategoryId ($ category_id); $ This- & gt; Data ['makers'] = array (); Forex Currency ($ Manufacturers $ as Manufacturer) {$ image = $ manufacturer ['image']; $ This- & gt; Data [manufacturers'] [] = array ( 'manufacturer_image' = & gt; $ this- & gt; model_tool_image- & change gt; size ($ results [ 'image'], 80,80), 'name' = Gt; $ result ['name'], 'href' => $ this-> url- & gt; link ('product / manufacturer / information', 'creator_id ='. $ Result ['manufacturer_id'] )); }   

I have not tested the above code, and if you want you can optimize the SQL query, but it should work properly.

No comments:

Post a Comment