【发布时间】:2015-05-27 18:00:25
【问题描述】:
我想在opencart 2.0的分类页面中添加产品选项。
我已经在\catalog\model\catalog\product.php 中添加了这段代码
public function hasOptionPriceIncrease($product_id) {
$option_data = $this->getProductOptions($product_id);
if (is_array($product_option_value)) {
foreach ($product_option_value as $option) {
if (is_array($option['product_option_value'])) {
foreach ($option['product_option_value'] as $value) {
if ($value['price'] > 1) {
return true;
}
}
}
} return false }
然后在 \controller\product\category.php 中
'has_option_price_increase' =>$this->model_catalog_product->hasOptionPriceIncrease($result['product_id'])
所以现在类别 $this->data['products'][] 变成了这样-
$this->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, 100) . '..',
'price' => $price,
'special' => $special,
'tax' => $tax,
'rating' => $result['rating'],
'reviews' => sprintf($this->language->get('text_reviews'), (int)$result['reviews']),
'href' => $this->url->link('product/product', 'path=' . $this->request->get['path'] . '&product_id=' . $result['product_id'] . $url),
'has_option_price_increase' =>$this->model_catalog_product->hasOptionPriceIncrease($result['product_id'])
);
现在我不明白如何在我的视图中调用它,即在 collection.tpl 中
请帮我在我的视图中显示这个,以便在类别页面中显示产品选项。
【问题讨论】:
-
嘿@jx12345,我看到你也做过同样的事情,你能帮我看看吗?哥们
-
您能否详细说明一下您希望如何在前端显示该价格?
标签: php opencart opencart2.x