在类别页面opencart中显示产品模型

display product model in category page opencart

我正在尝试在类别页面中显示产品型号。 我已经添加了 '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 } ?>

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

我还应该做什么?

确保 sql 查询包含模型字段。很多时候查询是特定的,而不是 return 数据库中的所有字段 table。 为此,导航到 catalog > model > catalog > product.php 并查找函数 getProducts
编辑此函数以允许模型。