我试图在opencart上 Build 一个单独的页面,它将列出新页面上的所有特色产品 .
即时通讯尝试编写将选择所有特色产品的SQL查询,但遗憾的是我无法在产品表上找到特色列 .
所以我试图复制特色模块
<?php
class ControllerProductFeatured extends Controller {
public function index($setting) {
$this->load->language('extension/module/featured');
$data['heading_title'] = $this->language->get('heading_title');
$data['text_tax'] = $this->language->get('text_tax');
$data['button_cart'] = $this->language->get('button_cart');
$data['button_wishlist'] = $this->language->get('button_wishlist');
$data['button_compare'] = $this->language->get('button_compare');
$this->load->model('catalog/product');
$this->load->model('tool/image');
$data['products'] = array();
if (!$setting['limit']) {
$setting['limit'] = 4;
}
if (!empty($setting['product'])) {
$products = array_slice($setting['product'], 0, (int)$setting['limit']);
foreach ($products as $product_id) {
$product_info = $this->model_catalog_product->getProduct($product_id);
if ($product_info) {
if ($product_info['image']) {
$image = $this->model_tool_image->resize($product_info['image'], $setting['width'], $setting['height']);
} else {
$image = $this->model_tool_image->resize('placeholder.png', $setting['width'], $setting['height']);
}
if ($this->customer->isLogged() || !$this->config->get('config_customer_price')) {
$price = $this->currency->format($this->tax->calculate($product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
} else {
$price = false;
}
if ((float)$product_info['special']) {
$special = $this->currency->format($this->tax->calculate($product_info['special'], $product_info['tax_class_id'], $this->config->get('config_tax')), $this->session->data['currency']);
} else {
$special = false;
}
if ($this->config->get('config_tax')) {
$tax = $this->currency->format((float)$product_info['special'] ? $product_info['special'] : $product_info['price'], $this->session->data['currency']);
} else {
$tax = false;
}
if ($this->config->get('config_review_status')) {
$rating = $product_info['rating'];
} else {
$rating = false;
}
$data['products'][] = array(
'product_id' => $product_info['product_id'],
'thumb' => $image,
'name' => $product_info['name'],
'description' => utf8_substr(strip_tags(html_entity_decode($product_info['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get($this->config->get('config_theme') . '_product_description_length')) . '..',
'price' => $price,
'special' => $special,
'tax' => $tax,
'rating' => $rating,
'href' => $this->url->link('product/product', 'product_id=' . $product_info['product_id'])
);
}
}
}
if ($data['products']) {
return $this->load->view('extension/module/featured', $data);
}
}
}
当我尝试访问我的页面index.php?route = product / featured它给我一个404错误 .
有人可以告诉我们在单独的页面中列出所有特色产品吗?
1 回答
转到扩展/扩展/模块并添加新的特色产品模块,并填写模块中的所有必需数据 .
现在,创建一个自定义布局
在设计/布局部分中创建一个新的自定义布局,例如名称为精选 .
将商店添加到您的商店名称和路线作为common / home .
将特色产品模块分配到所需位置 .
创建一个类别(您可以从中访问)
现在创建一个新类别,将其称为精选 .
填写类别中的所有必需数据
将设计布局指定为精选(创建新布局名称)
转到店面并打开您创建的类别 .
希望这个答案能帮到你 .