繁体   English   中英

opencart单独页面中的特色产品

[英]featured products in a separate page in opencart

我试图在opencart上建立一个单独的页面,该页面将在新页面上列出所有特色产品。

我试图编写将选择所有特色产品的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. 在设计/版面部分中创建一个新的自定义版面,将其名称称为Featured。
  2. 将商店添加到您的商店名称,然后将路径作为通用/家。
  3. 将特色产品模块分配到所需位置。

创建类别(可从中访问)

  1. 现在创建一个新类别,称其为Featured。
  2. 填写类别中的所有必需数据
  3. 将设计版面分配为“特色”(创建的新版面名称)

转到店面并打开您创建的类别。

希望这个答案对您有所帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM