0

有没有办法在 Opencart v1.5.5.1 的愿望清单中列出的每个产品名称旁边添加类别名称?

我尝试将其添加到wishlist.tpl,但没有奏效:

<?php foreach ($categories as $category) { ?>
<li><a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a>
<?php } ?>

还有我在另一篇文章中找到的代码,它适用于 product.tpl 模板:

<?php
$this->load->model('catalog/category');
$query = $this->db->query("SELECT category_id
FROM oc_product_to_category
WHERE product_id = '".$product_id."'");
$prodcategories = $query->rows;
foreach($prodcategories as $prodcategory){
$category_id = $prodcategory['category_id'];
$category_info = $this->model_catalog_category->getCategory($category_id);
$caturl = (HTTP_SERVER . 'index.php?route=product/category&path=' . $category_id); ?>
Category : <a href="<?php echo $caturl; ?>"><?php echo $category_info['name']; ?></a><br />
<?php  }  ?>
4

1 回答 1

0

在文件中

catalog/controller/account/wishlist.php

在第 108 行附近的某处,在代码块之前添加 product.tpl 代码

$this->data['products'][] = array(
                    'product_id' => $product_info['product_id'],
                    'thumb'      => $image,
                    'name'       => $product_info['name'],
                    'model'      => $product_info['model'],
                    'stock'      => $stock,
                    'price'      => $price,     
                    'special'    => $special,
                    'href'       => $this->url->link('product/product', 'product_id=' . $product_info['product_id']),
                    'remove'     => $this->url->link('account/wishlist', 'remove=' . $product_info['product_id'])
                );

添加类别名称作为产品的属性之一,例如

                'categoryname' => $categoryinfoARRAY and then in the wishlist.tpl each product will have its associated categoryname .
于 2013-03-24T14:25:31.580 回答