Jump to content
Sign in to follow this  
max1985

[Решено] Автоматическое добавление похожих товаров

Recommended Posts

Нашел такое решение:

 

в файле catalog/model/catalog/product.php

 

после кода

foreach ($query->rows as $result) { 
			if( $product_id != $result['related_id'] )$product_data[$result['related_id']] = $this->getProduct($result['related_id']);
		}

добавить

 

$max_related = 4;


$num_related = $max_related - count($product_data);
if($num_related > 0)
{    
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_to_category p2c LEFT JOIN " . DB_PREFIX . "product p ON (p2c.product_id = p.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE p2c.category_id IN (SELECT category_id FROM " . DB_PREFIX . "product_to_category WHERE product_id = '" . (int)$product_id . "') AND p.product_id != '" . (int)$product_id . "' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' ORDER BY RAND() LIMIT 0," . $num_related); 


foreach ($query->rows as $result) { 
$product_data[$result['product_id']] = $this->getProduct($result['product_id']);
}
}


$num_related = $max_related - count($product_data);
if($num_related > 0)
{ 


$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE p.manufacturer_id IN (SELECT manufacturer_id FROM " . DB_PREFIX . "product WHERE product_id = '" . (int)$product_id . "') AND p.product_id != '" . (int)$product_id . "' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' ORDER BY RAND() LIMIT 0," . $num_related); 


foreach ($query->rows as $result)
$product_data[$result['product_id']] = $this->getProduct($result['product_id']);  
   
return $product_data;
}

Товары появились, но ссылка на похожие товары получилась немного не правильная, т.е. в ссылке нет /категория/

 

Должно быть так:

сайт.ру/категория/товар.html

А на самом деле так:

сайт.ру/товар.html

 

 

Помогите пожалуйста исправить код! Спасибо!

Share this post


Link to post
Share on other sites

Заметил это даже происходит при добавлении любого модуля с товарами: Последние поступления, Случайные и т.д.

Помогите пожалуйста!

Share this post


Link to post
Share on other sites

Все решилось установкой SeoPro

 

P.S. Не пойме на этом форуме кто-то вообще есть? Наверное придется искать альтернативу.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×

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.