【问题标题】:How can i get manufacturer image in manucarturer page in opencart2.0.2.0?如何在 opencart2.0.2.0 的制造商页面中获取制造商图像?
【发布时间】:2016-01-08 13:22:00
【问题描述】:

我正在使用 opencart 版本 2.0.2.0,现在我正在尝试在制造商页面中获取图像或图像 url。

我已经在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 in /data1/opencart-2.0.2.0/catalog/view/theme/default/template/product/manufacturer_list.tpl 在第 32 行数组

【问题讨论】:

  • 您似乎对制造商列表页面和详细信息页面感到困惑,
  • 我一点都不迷茫,我想在制造商列表页面显示图像,谢谢!

标签: image syntax-error opencart2.x


【解决方案1】:

让我们清楚ControllerProductManufacturer index() 显示列表,info() 显示制造的详细信息,

//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;?>

【讨论】:

    猜你喜欢
    • 2011-05-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-30
    • 2022-01-10
    相关资源
    最近更新 更多