рекомендуемые продукты на отдельной странице в opencart - PullRequest
0 голосов
/ 25 апреля 2018

Я пытаюсь создать отдельную страницу на 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 /Рекомендуемые это дает мне ошибку 404.

Может кто-нибудь сказать, пожалуйста, способ перечислить все рекомендуемые продукты на отдельной странице?

1 Ответ

0 голосов
/ 08 мая 2018

Перейдите к расширениям / расширениям / модулю и добавьте новый модуль рекомендуемого продукта и заполните все необходимые данные в модуле.

Теперь создайте пользовательский макет

  1. Создайтеновый пользовательский макет в разделе «Дизайн / макеты», произнесите имя как Featured.
  2. Добавьте название магазина в ваш магазин и укажите маршрут как общий / home.
  3. Присвойте модуль рекомендуемого продукта требуемой позиции.

Создание категории (откуда вы можете получить к ней доступ)

  1. Теперь создайте новую категорию, назовите ее «Избранная».
  2. Заполните все необходимые данные вкатегория
  3. Назначение макета дизайна как избранного (Создано новое имя макета)

Перейдите в магазин и откройте созданную вами категорию.

Надеюсь, этот ответ помог вам.

...