2015-10-10 39 views
0

我正在使用opencart版本2.0.2.0,現在我正試圖在製造商頁面中獲取圖像或圖像URL。如何在opencart2.0.2.0的manucarturer頁面中獲取製造商圖像?

我在catalog/controller/product/manufacturer.php

$manufacturer_image = $this->model_catalog_manufacturer->getManufacturer($manufacturer_id); 

     if($manufacturer_image){ 
      $this->data['manufacturers_img'] = $this->model_tool_image->resize($manufacturer_image['image'], 120, 120); 
     }else{ 
      $this->data['manufacturers_img'] = false; 
     } 

添加的代碼,並調用它在catalog/view/theme/default/template/product/manufacturer_list.tpl

<div class="row"> 
    <?php foreach ($manufacturers as $manufacturer) { ?> 
    <div class="col-sm-3"><a href="<?php echo $manufacturer['href']; ?>"><?php echo $manufacturer['name']; ?></a> 
     <?php echo ($manufacturers_img) ? '<img src="'.$manufacturers_img.'" alt="'.$manufacturers.'" />' : $manufacturers ;?><br /> 
    </div> 
    <?php } ?> 
    </div> 

但它越來越錯誤在我/index.php?route=product/manufacturer

注意:未定義的變量:manufacturers_img在 /data1/opencart-2.0.2.0/catalo克/視圖/主題/默認/模板/產品/ manufacturer_list.tpl線 32Array

+0

好像您正在使用,製造商列表頁和詳細信息頁混淆, – Ramesh

+0

我不困惑可言,我想在製造商列表頁面中顯示的圖像,謝謝! –

回答

0

讓清楚ControllerProductManufacturerindex()顯示列表並info()顯示MFG的細節,

//catalog/controller/product/manufacturer.php:46 

替換

$data['categories'][$key]['manufacturer'][] = array(

$manufacturer_image = $this->model_catalog_manufacturer->getManufacturer($result['manufacturer_id']); 

if($manufacturer_image){ 
$mfg_img = $this->model_tool_image->resize($manufacturer_image['image'], 120, 120); 
}else{ 
$mfg_img = false; 
} 

$data['categories'][$key]['manufacturer'][] = array(
'image'=>$mfg_img, 

而且在catalog/view/theme/default/template/product/manufacturer_list.tpl:30 內環

<?php if($manufacturer['image']):?> 
    <img src="<?php echo $manufacturer['image']; ?>" alt="<?php echo $manufacturer['name'];?>"> 
<?php endif;?> 
相關問題