Search the Community
Showing results for tags 'аналоги'.
-
Вопрос такой как вывести товары на основе похожих товаров ! Мной было реализовано следующие правки ! catalog/controller/product/search.php $results = $this->model_catalog_product->getProducts($data); //Вызов метода getFoundProducts должен проводится сразу же после getProducts //только тогда он выдает правильное значения количества товаров $product_total = $this->model_catalog_product->getFoundProducts(); foreach ($results as $result) { if ($result['image']) { $image = $this->model_tool_image->resize($result['image'], $this->config->get('config_image_product_width'), $this->config->get('config_image_product_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_tax')) { $tax = $this->currency->format((float) $result['special'] ? $result['special'] : $result['price']); } else { $tax = false; } if ($this->config->get('config_review_status')) { $rating = (int) $result['rating']; } else { $rating = false; } /*original*/ $resultsRelated = $this->model_catalog_product->getProductRelated($result['product_id']); foreach ($resultsRelated as $resultRelated) { if ($result['image']) { $image_related = $this->model_tool_image->resize($resultRelated['image'], $this->config->get('config_image_related_width'), $this->config->get('config_image_related_height')); } else { $image_related = false; } if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) { $price_resultRelated = $this->currency->format($this->tax->calculate($resultRelated['price'], $resultRelated['tax_class_id'], $this->config->get('config_tax'))); } else { $price_resultRelated = false; } if ((float) $resultRelated['special']) { $special = $this->currency->format($this->tax->calculate($resultRelated['special'], $resultRelated['tax_class_id'], $this->config->get('config_tax'))); } else { $special = false; } if ($this->config->get('config_review_status')) { $rating = (int) $resultRelated['rating']; } else { $rating = false; } $related[$result['product_id']][] = array( 'product_id_original' => $resultRelated['product_id'], 'thumb_original' => $image_related, 'name_original' => utf8_substr(strip_tags(html_entity_decode($resultRelated['name'], ENT_QUOTES, 'UTF-8')), 0, 26) . '', 'manufacturer_original' => $resultRelated['manufacturer'], 'original' => $resultRelated['original'], 'location_original' => $resultRelated['location'], 'minimum_original' => $resultRelated['minimum'], 'date_available_original' => $resultRelated['date_available'], 'quantity_original' => $resultRelated['quantity'], 'price_original' => $price_resultRelated, 'mode_originall' => $resultRelated['model'], 'model_no_original' => utf8_substr(strip_tags(html_entity_decode($resultRelated['model'], ENT_QUOTES, 'UTF-8')), 0, 1) . '____' . utf8_substr(strip_tags(html_entity_decode($resultRelated['model'], ENT_QUOTES, 'UTF-8')), -1) . '', 'special_original' => $special, 'rating_original' => $rating, 'description_original' => utf8_substr(strip_tags(html_entity_decode($resultRelated['description'], ENT_QUOTES, 'UTF-8')), 0, 300) . '', 'tax_original' => $tax, 'reviews_original' => sprintf($this->language->get('text_reviews'), (int) $resultRelated['reviews']), 'man_info_original' => $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $resultRelated['manufacturer_id']), 'href_original' => $this->url->link('product/product', 'product_id=' . $resultRelated['product_id']) ); } /*neoriginal*/ $resultsRelatedNeoriginal = $this->model_catalog_product->getProductRelatedNeoriginal($result['product_id']); foreach ($resultsRelatedNeoriginal as $resultRelatedNeoriginal) { if ($result['image']) { $image = $this->model_tool_image->resize($resultRelatedNeoriginal['image'], $this->config->get('config_image_related_width'), $this->config->get('config_image_related_height')); } else { $image = false; } if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) { $price_resultRelatedNeoriginal = $this->currency->format($this->tax->calculate($resultRelatedNeoriginal['price'], $resultRelatedNeoriginal['tax_class_id'], $this->config->get('config_tax'))); } else { $price_resultRelatedNeoriginal = false; } if ((float) $resultRelatedNeoriginal['special']) { $special = $this->currency->format($this->tax->calculate($resultRelatedNeoriginal['special'], $resultRelatedNeoriginal['tax_class_id'], $this->config->get('config_tax'))); } else { $special = false; } if ($this->config->get('config_review_status')) { $rating = (int) $resultRelatedNeoriginal['rating']; } else { $rating = false; } $related_neoriginal[$result['product_id']][] = array( 'product_id_neoriginal' => $resultRelatedNeoriginal['product_id'], 'thumb_neoriginal' => $image, 'name_neoriginal' => utf8_substr(strip_tags(html_entity_decode($resultRelatedNeoriginal['name'], ENT_QUOTES, 'UTF-8')), 0, 26) . '', 'manufacturer_neoriginal' => $resultRelatedNeoriginal['manufacturer'], 'minimum_neoriginal' => $resultRelatedNeoriginal['minimum'], 'location_neoriginal' => $resultRelatedNeoriginal['location'], 'original_neoriginal' => $resultRelatedNeoriginal['original'], 'quantity_neoriginal' => $resultRelatedNeoriginal['quantity'], 'date_available_neoriginal' => $resultRelatedNeoriginal['date_available'], 'description_neoriginal' => utf8_substr(strip_tags(html_entity_decode($resultRelatedNeoriginal['description'], ENT_QUOTES, 'UTF-8')), 0, 300) . '', 'price_neoriginal' => $price_resultRelatedNeoriginal, 'model_neoriginal' => $resultRelatedNeoriginal['model'], 'model_no_neoriginal' => utf8_substr(strip_tags(html_entity_decode($resultRelatedNeoriginal['model'], ENT_QUOTES, 'UTF-8')), 0, 1) . '____' . utf8_substr(strip_tags(html_entity_decode($resultRelatedNeoriginal['model'], ENT_QUOTES, 'UTF-8')), -1) . '', 'special_neoriginal' => $special, 'rating_neoriginal' => $rating, 'tax_neoriginal' => $tax, 'reviews_neoriginal' => sprintf($this->language->get('text_reviews'), (int) $resultRelatedNeoriginal['reviews']), 'man_info_neoriginal' => $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $resultRelatedNeoriginal['manufacturer_id']), 'href_neoriginal' => $this->url->link('product/product', 'product_id=' . $resultRelatedNeoriginal['product_id']) ); } /*komplect*/ $resultsRelatedKomplect = $this->model_catalog_product->getProductRelatedKomplect($result['product_id']); foreach ($resultsRelatedKomplect as $resultRelatedKomplect) { if ($result['image']) { $image = $this->model_tool_image->resize($resultRelatedKomplect['image'], $this->config->get('config_image_related_width'), $this->config->get('config_image_related_height')); } else { $image = false; } if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) { $price_resultRelatedKomplect = $this->currency->format($this->tax->calculate($resultRelatedKomplect['price'], $resultRelatedKomplect['tax_class_id'], $this->config->get('config_tax'))); } else { $price_resultRelatedKomplect = false; } if ((float) $resultRelatedKomplect['special']) { $special = $this->currency->format($this->tax->calculate($resultRelatedKomplect['special'], $resultRelatedKomplect['tax_class_id'], $this->config->get('config_tax'))); } else { $special = false; } if ($this->config->get('config_review_status')) { $rating = (int) $resultRelatedKomplect['rating']; } else { $rating = false; } $related_komplect[$result['product_id']][] = array( 'product_id_komplect' => $resultRelatedKomplect['product_id'], 'thumb_komplect' => $image, 'name_komplect' => utf8_substr(strip_tags(html_entity_decode($resultRelatedKomplect['name'], ENT_QUOTES, 'UTF-8')), 0, 26) . '', 'manufacturer_komplect' => $resultRelatedKomplect['manufacturer'], 'date_available_komplect' => $resultRelatedKomplect['date_available'], 'description_komplect' => utf8_substr(strip_tags(html_entity_decode($resultRelatedKomplect['description'], ENT_QUOTES, 'UTF-8')), 0, 300) . '', 'original' => $resultRelatedKomplect['original'], 'minimum_komplect' => $resultRelatedKomplect['minimum'], 'quantity_komplect' => $resultRelatedKomplect['quantity'], 'price_komplect' => $price_resultRelatedKomplect, 'model_komplect' => $resultRelatedKomplect['model'], 'model_no_komplect' => utf8_substr(strip_tags(html_entity_decode($resultRelatedKomplect['model'], ENT_QUOTES, 'UTF-8')), 0, 1) . '____' . utf8_substr(strip_tags(html_entity_decode($resultRelatedKomplect['model'], ENT_QUOTES, 'UTF-8')), -1) . '', 'special_komplect' => $special, 'rating_komplect' => $rating, 'tax_komplect' => $tax, 'reviews_komplect' => sprintf($this->language->get('text_reviews'), (int) $resultRelatedKomplect['reviews']), 'man_info_komplect' => $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $resultRelatedKomplect['manufacturer_id']), 'href_komplect' => $this->url->link('product/product', 'product_id=' . $resultRelatedKomplect['product_id']) ); } // $categories - содержит оприделенный товар найденный по ID $categories = $this->model_catalog_product->getCategories($result['product_id']); // $categories_info - содержит оприделенную категорию найденную по ID $categories_info = $this->model_catalog_category->getCategory($categories[0]['category_id']); // В этом массиве добавляем 'related' и определяем её как вложенный массив сопутствующих товаров, который найден выше $this->data['products'][] = array( 'product_id' => $result['product_id'], 'thumb' => $image, 'minimum' => $result['minimum'], 'name' => utf8_substr(strip_tags(html_entity_decode($result['name'], ENT_QUOTES, 'UTF-8')), 0, 26) . '', 'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, 300) . '', 'quantity' => $result['quantity'], 'model' => utf8_substr(strip_tags(html_entity_decode($result['model'], ENT_QUOTES, 'UTF-8')), 0, 20) . '', 'model_no' => utf8_substr(strip_tags(html_entity_decode($result['model'], ENT_QUOTES, 'UTF-8')), 0, 1) . '____' . utf8_substr(strip_tags(html_entity_decode($result['model'], ENT_QUOTES, 'UTF-8')), -1) . '', 'manufacturer' => $result['manufacturer'], 'original' => $result['original'], 'price' => $price, 'zakup_price' => $result['zakup_price'], 'name_group' => $result['name'], 'location' => $result['location'], 'special' => $special, 'tax' => $tax, 'rating' => $result['rating'], 'date_available' => $result['date_available'], 'reviews' => sprintf($this->language->get('text_reviews'), (int) $result['reviews']), 'man_info' => $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $result['manufacturer_id']), 'href' => $this->url->link('product/product', 'product_id=' . $result['product_id']), 'related' => isset($related[$result['product_id']]) ? $related[$result['product_id']] : array(), 'related_neoriginal' => isset($related_neoriginal[$result['product_id']]) ? $related_neoriginal[$result['product_id']] : array(), 'related_komplect' => isset($related_komplect[$result['product_id']]) ? $related_komplect[$result['product_id']] : array(), 'description_dop' => html_entity_decode($categories_info['description_dop'], ENT_QUOTES, 'UTF-8') ); } Также /catalog/model/catalog/product public function getProductRelated($product_id) { $product_data = array(); $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_related pr LEFT JOIN " . DB_PREFIX . "product p ON (pr.related_id = p.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE pr.product_id = '" . (int)$product_id . "' AND p.status = '1' AND p.date_available <= '" . $this->NOW . "' AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'"); foreach ($query->rows as $result) { if( $product_id != $result['related_id'] )$product_data[$result['related_id']] = $this->getProduct($result['related_id']); } return $product_data; } /*Neoriginal*/ public function getProductRelatedNeoriginal($product_id) { $product_data = array(); $query_neoriginal = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_related_neoriginal pr LEFT JOIN " . DB_PREFIX . "product p ON (pr.related_id = p.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE pr.product_id = '" . (int)$product_id . "' AND p.status = '1' AND p.date_available <= '" . $this->NOW . "' AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'"); foreach ($query_neoriginal->rows as $result_neoriginal) { if( $product_id != $result_neoriginal['related_id'] )$product_data[$result_neoriginal['related_id']] = $this->getProduct($result_neoriginal['related_id']); } return $product_data; } /*komplect */ public function getProductRelatedKomplect($product_id) { $product_data = array(); $query_komplect = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_related_komplect pr LEFT JOIN " . DB_PREFIX . "product p ON (pr.related_id = p.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE pr.product_id = '" . (int)$product_id . "' AND p.status = '1' AND p.date_available <= '" . $this->NOW . "' AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'"); foreach ($query_komplect->rows as $result_komplect) { if( $product_id != $result_komplect['related_id'] )$product_data[$result_komplect['related_id']] = $this->getProduct($result_komplect['related_id']); } return $product_data; } теперь смотри у меня есть два товар ! к одному привязаны аналоги Делаем поиск у себя на сайте если я буду искать sn947 то мне покажет два товара все верно ! Теперь скопируем один из оригинальных аналогов и сделаем поиск ! В поиске покажет только тот товар который привязан SN947 но у меня есть еще товар SN947 от другово поставщика как мне его отобразить !? Я долго думал может нужно запрос подправить но потом ведь у меня есть product_id кароче запустался пацаны выручайте