2016-08-22 90 views
0

我尝试添加模型和制造商名称在搜索结果页面上显示(OC版本2.2.0.0)。我有解决方案,可以在Opencart v 1.5.6 +上运行。Opencart 2.2.0.0未定义的搜索结果页索引

1.我已经加入此代码到/catalog/controller/product/search.php

'manufacturer' => $result['manufacturer'], 
'model' => $result['model'], 

此代码:

$data['products'][] = array(
      'product_id' => $result['product_id'], 
      'thumb'  => $image, 
      'name'  => $result['name'], 
      'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get($this->config->get('config_theme') . '_product_description_length')) . '..', 
      'price'  => $price, 
      'special'  => $special, 
      'tax'   => $tax, 
      'minimum'  => $result['minimum'] > 0 ? $result['minimum'] : 1, 
      'rating'  => $result['rating'], 
      'href'  => $this->url->link('product/product', 'product_id=' . $result['product_id'] . $url) 
     ); 
    } 

2.在/目录/查看/主题/默认/模板/产品/ search.tpl我已添加此代码:

在“div class caption”我试着打电话这名以

<?php echo $product['model']; ?> 
<?php echo $product['manufacturer']; ?> 

结果:在版本2.2 OC错误UNDEFINED INDEX。在Opencart 1上,此代码完美无缺。

任何消耗?

+0

一定要检查值是否正确传递给数组中的这些键。未定义的索引是当有一个没有赋值的属性时。 – g9m29

+0

你好,谢谢你的回答。 Mayby你知道我在哪里可以找到Opencart CMS文件中的所有密钥? –

回答

0

Hola a mi me funcionoasí。 encontroller category.php

   $data['products'][] = array(
       'product_id' => $result['product_id'], 
       'manufacturer' => $result['manufacturer'], 
       'thumb'  => $image, 
       'name'  => $result['name'], 
       'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get($this->config->get('config_theme') . '_product_description_length')) . '..', 
       'price'  => $price, 
       'special'  => $special, 
       'tax'   => $tax, 
       'minimum'  => $result['minimum'] > 0 ? $result['minimum'] : 1, 
       'rating'  => $result['rating'], 
       'href'  => $this->url->link('product/product', 'path=' . $this->request->get['path'] . '&product_id=' . $result['product_id'] . $url) 
      );