【问题标题】:display product model in category page opencart在类别页面opencart中显示产品型号
【发布时间】:2016-04-11 21:31:23
【问题描述】:

我正在尝试在类别页面中显示产品型号。 我已经添加了 'model'=> $result['model'] 在 /catalog/controller/product/category.php

$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('config_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),
                    'model'       => $result['model']
                );

我还在产品 foreach 中使用以下代码编辑了 category.tpl

<?php if (!empty($product['model'])) { ?>
                    <h5 class="model">&nbsp;<?php echo $product['model']; ?></h5>
                <?php } ?>

但类别页面中没有显示任何内容。

我还能做什么?

【问题讨论】:

  • 尝试将 'model' 设置为静态文本,以测试 .tpl 文件是否至少能够正确显示
  • 我替换了价格,名称,在这两种情况下我都得到了未定义的索引错误
  • Agis Soleas,尝试在 category.php 文件中 print_r($results) 并检查它是否给出模型的结果?

标签: opencart


【解决方案1】:

确保 sql 查询包含模型字段。很多时候查询是特定的,不会返回数据库表中的所有字段。 为此,请导航至 catalog &gt; model &gt; catalog &gt; product.php 并查找函数 getProducts
编辑此函数以允许模型。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-02-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多