Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

kimxan123

Newbie
  
  • Posts

    6
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

kimxan123's Achievements

Rookie

Rookie (2/14)

  • First Post
  • Week One Done
  • One Month Later
  • One Year In
  • Conversation Starter

Recent Badges

0

Reputation

  1. Все решено. Большое спасибо @ auditor. Навёл на ошибку. Всё-таки проблема с модификаторами. Так что дорогие друзья, чистим модификаторы)))) Всем спасибо за внимание!
  2. Данный запрос работает на прямую в базу, на примере определенного product_id. Этого разве не достаточно?
  3. Последовал вашим рекомендациям public function getProductSimilar($product_id) { $product_sku_data = array(); $sql = "SELECT product_id FROM " . DB_PREFIX . "product WHERE price > 0 AND product_id != '" . (int)$product_id . "' AND sku = (SELECT DISTINCT sku FROM " . DB_PREFIX . "product WHERE product_id = '" . (int)$product_id . "') AND price < (SELECT DISTINCT price FROM " . DB_PREFIX . "product WHERE product_id = '" . (int)$product_id . "') ORDER BY price"; $this->log->write('sql_req:'.$sql); $query = $this->db->query($sql); foreach ($query->rows as $result) { $product_sku_data[$result['product_id']] = $this->getProduct($result['product_id']); } return $product_sku_data; } Снова почистил весь кеш Положительных результатов нет. Журнал пуст
  4. Весь кеш почистил, но к сожалению никаких результатов
  5. Всем доброго времени суток! Недавно познакомился с Opencart 3. Пытаюсь написать модуль, для страницы карточка товара, который будет выводить похожие товары по следующим параметрам: SKU, Price Написал функцию в model_catalog_product: public function getProductSimilar($product_id) { $product_sku_data = array(); if ($product_id) { $query = $this->db->query("SELECT product_id FROM " . DB_PREFIX . "product WHERE price > 0 AND product_id != '" . (int)$product_id . "' AND sku = (SELECT DISTINCT sku FROM " . DB_PREFIX . "product WHERE product_id = '" . (int)$product_id . "') AND price < (SELECT DISTINCT price FROM " . DB_PREFIX . "product WHERE product_id = '" . (int)$product_id . "') ORDER BY price"); foreach ($query->rows as $result) { $product_sku_data[$result['product_id']] = $this->getProduct($result['product_id']); } } return $product_sku_data; } Для реализации решил использовать встроенный модуль special Переписал контроллер catalog_controller_extension_module_special: <?php class ControllerExtensionModuleSpecial extends Controller { public function index($setting) { $this->load->language('extension/module/special'); $this->load->model('catalog/product'); $this->load->model('tool/image'); $data['products'] = array(); $product_id = isset($this->request->get['product_id']) ? $this->request->get['product_id'] : 0; $results = $this->model_catalog_product->getProductSimilar($product_id); foreach ($results as $result) { if ($result['image']) { $image = $this->model_tool_image->resize($result['image'], $setting['width'], $setting['height']); } else { $image = false; } if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) { $price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax'))); } else { $price = false; } if ((float)$result['special']) { $special = $this->currency->format($this->tax->calculate($result['special'], $result['tax_class_id'], $this->config->get('config_tax'))); } else { $special = false; } if ($this->config->get('config_review_status')) { $rating = $result['rating']; } else { $rating = false; } $this->data['products'][] = array( 'product_id' => $result['product_id'], 'thumb' => $image, 'name' => $result['name'], 'price' => $price, 'special' => $special, 'rating' => $rating, 'reviews' => sprintf($this->language->get('text_reviews'), (int)$result['reviews']), 'href' => $this->url->link('product/product', 'product_id=' . $result['product_id']), ); } return $this->load->view('extension/module/special', $data); } } Пытаюсь вывести на странице карточки товаров, ничего не выводится, даже заголовок модуля. Пожалуйста, подскажите, что не так я делаю? Заранее огромное спасибо!
×
×
  • Create New...

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.