2014-03-29 64 views
1

Hy guys,即時preaty新來opencart,我需要你的幫助。 我設法在產品頁面上添加製造商的徽標,但知道我想在特色產品中顯示製造商的徽標。 我設法增加製造商的名字,但不知道如何使用OC 1.5.5.1如何在特色產品模塊中添加製造商徽標? | Opencart

這是我featured.php代碼得到它:(IM的IMG鏈接:

<?php 
class ControllerModuleFeatured extends Controller { 
    //alex start 
    protected function index($setting) { 
     $this->language->load('module/featured'); 

     $this->data['heading_title'] = $this->language->get('heading_title'); 

     $this->data['button_cart'] = $this->language->get('button_cart'); 

     $this->load->model('catalog/product'); 

     $this->load->model('tool/image'); 

     $this->data['products'] = array(); 

     $products = explode(',', $this->config->get('featured_product'));  

     if (empty($setting['limit'])) { 
      $setting['limit'] = 5; 
     } 

     $products = array_slice($products, 0, (int)$setting['limit']); 

     foreach ($products as $product_id) { 
      $product_info = $this->model_catalog_product->getProduct($product_id); 

      if ($product_info) { 
       if ($product_info['image']) { 
        $image = $this->model_tool_image->resize($product_info['image'], $setting['image_width'], $setting['image_height']); 
       } else { 
        $image = false; 
       } 

       if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) { 
        $price = $this->currency->format($this->tax->calculate($product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax'))); 
       } else { 
        $price = false; 
       } 

       if ((float)$product_info['special']) { 
        $special = $this->currency->format($this->tax->calculate($product_info['special'], $product_info['tax_class_id'], $this->config->get('config_tax'))); 
       } else { 
        $special = false; 
       } 

       if ($this->config->get('config_review_status')) { 
        $rating = $product_info['rating']; 
       } else { 
        $rating = false; 
       } 

       $this->data['products'][] = array(
        'product_id'  => $product_info['product_id'], 
        'thumb'   => $image, 
        'name'   => $product_info['name'], 
        'manufacturer' => $product_info['manufacturer'],    
        'manufacturer_id' => $product_info['manufacturer_id'], 
        //'manufacturer_img'=> $product_info['manufacturer_img'], 
        'manufacturers' => $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $product_info['manufacturer_id']), 
        'price'   => $price, 
        'special'   => $special, 
        'rating'   => $rating, 
        'reviews'   => sprintf($this->language->get('text_reviews'), (int)$product_info['reviews']), 
        'href'   => $this->url->link('product/product', 'product_id=' . $product_info['product_id']) 
       ); 
      } 
     } 


     if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/featured.tpl')) { 
      $this->template = $this->config->get('config_template') . '/template/module/featured.tpl'; 
     } else { 
      $this->template = 'default/template/module/featured.tpl'; 
     } 

     $this->render(); 
    } 
} 
?> 

回答

1

你。必須通過將m.image AS manufacturer_img,添加到getProduct函數的現有選擇查詢來修改產品的型號文件。請參閱以下代碼片段:

............... .......

$query = $this->db->query("SELECT DISTINCT *, pd.name AS name, p.image, m.name AS manufacturer, `m.image AS manufacturer_img,` (SELECT price ... 

................

然後添加'manufacturer_img' => $query->row['manufacturer_img'],到返回數組:

................ .......

'manufacturer_id' => $query->row['manufacturer_id'], 
'manufacturer_img' => $query->row['manufacturer_img'], 
'manufacturer'  => $query->row['manufacturer'], 

......................

最後的功能模塊catalog/controller/module/featured.php正如你上確實,您可以添加此代碼段代碼以獲取產品的製造商相關數據:

............................

'manufacturer' => $product_info['manufacturer'], 
'manufacturer_id' => $product_info['manufacturer_id'], 
'manufacturer_img'=> $product_info['manufacturer_img'], 
+0

非常感謝您的回答,我將修改爲u recomended並將返回一個反饋。 –

+0

工作就像一個魅力!非常感謝您的幫助! –

+0

@AlbertO。如果這解決了您的問題,請點擊此帖子左側的*勾號接受此答案。接受正確的答案有助於其他用戶搜索相同/相似的問題,以確定接受答案的問題,以便他們能夠更輕鬆,更快地找到解決問題的方法。 (可選)您可能想要贊成答案以及它很好地完成。將此視爲*謝謝*,以幫助解決您的問題。 – shadyyx

相關問題