Показ схожих информационных элементов на основе меток

#
Re: Показ схожих информационных элементов на основе меток
Помогите пожалуйста разобраться???
#
Re: Показ схожих информационных элементов на основе меток
Добрый день!
Есть ли у кого готовое аналогичное решение «Показ схожих товаров интернет-магазина на основе меток»?
Было бы очень неплохо! Помогите!
#
Re: Показ схожих информационных элементов на основе меток
kamardindg,
берете тот же код и меняете все Informationsystem на Shop
www.morozovpimnev.ru - создание, поддержка и продвижение сайтов | Наш канал https://asmp.su/channel
#
Re: Показ схожих информационных элементов на основе меток
Всё сделал по инструкции, но на сайте выводится вот такое.
То есть, вместо четырёх совпавших по тегам товаров, выводится название самого интернет-магазина…
Посоветуйте, что сделать? Что мне надо изменить?
#
Re: Показ схожих информационных элементов на основе меток
#
Re: Показ схожих информационных элементов на основе меток
… и какой-то «NaN» в придачу…
#
Re: Показ схожих информационных элементов на основе меток
kamardindg,
а код то покажите
www.morozovpimnev.ru - создание, поддержка и продвижение сайтов | Наш канал https://asmp.su/channel
#
Re: Показ схожих информационных элементов на основе меток
Типовая динамическая страница интернет-магазина:

<?php
$oShop = Core_Entity::factory('Shop', Core_Array::get(Core_Page::instance()->libParams, 'shopId'));
$Shop_Controller_Show = new Shop_Controller_Show($oShop);


$oShop_Item = Core_Entity::factory('Shop_Item', $Shop_Controller_Show->item);
$oTag_Shop_Items = $oShop_Item->Tag_Shop_Items->findAll();
// Минимальное количество тегов для совпадения.
$iSameTags = 3;
$aTagIds = array();
foreach($oTag_Shop_Items as $oTag_Shop_Item) {
$aTagIds[] = $oTag_Shop_Item->tag_id;
} if (count($aTagIds)) {
$oSameTag_Shop_Items = Core_Entity::factory('Tag_Shop_Item');
$oSameTag_Shop_Items->queryBuilder()
->select('tag_Shop_items.*')
->where('tag_id', 'IN', $aTagIds)
->where('tag_Shop_items.Shop_item_id', '!=', $oShop_Item->id)
->join('Shop_items', 'tag_Shop_items.Shop_item_id', '=', 'Shop_items.id')
->join('Shops', 'Shop_items.Shop_id', '=', 'Shops.id')
->where('Shops.site_id', '=', CURRENT_SITE)
->groupBy('Shop_items.id')
->having('COUNT(tag_id)', '>=', $iSameTags)
->clearOrderBy()
->orderBy('RAND()')
->limit(4);
$aSameTag_Shop_Items = $oSameTag_Shop_Items->findAll();
$oXmlSamenews = Core::factory('Core_Xml_Entity')->name('samenews');
$Shop_Controller_Show->addEntity($oXmlSamenews);
foreach($aSameTag_Shop_Items as $oSameTag_Shop_Item) {
$oXmlSamenews->addEntity(
$oSameTag_Shop_Item->Shop_Item->clearEntities()
);
} }



$Shop_Controller_Show
->limit($oShop->items_on_page)
->parseUrl();
// Обработка скачивания файла электронного товара
$guid = Core_Array::getGet('download_file');
if (strlen($guid)) {
$oShop_Order_Item_Digital = Core_Entity::factory('Shop_Order_Item_Digital')->getByGuid($guid);
if (!is_null($oShop_Order_Item_Digital) && $oShop_Order_Item_Digital->Shop_Order_Item->Shop_Order->shop_id == $oShop->id) {
$iDay = 7;
// Проверяем, доступна ли ссылка (Ссылка доступна в течение суток после оплаты)
if (Core_Date::sql2timestamp($oShop_Order_Item_Digital->Shop_Order_Item->Shop_Order->payment_datetime) > time() - 24 * 60 * 60 * $iDay) {
$oShop_Item_Digital = $oShop_Order_Item_Digital->Shop_Item_Digital;
if ($oShop_Item_Digital->filename != '') {
Core_File:ownload($oShop_Item_Digital->getFullFilePath(), $oShop_Item_Digital->filename);
exit();
}
}
else {
Core_Message::show(Core::_('Shop_Order_Item_Digital.time_is_up', $iDay));
}
}
Core_Page::instance()->response->status(404)->sendHeaders()->showBody();
exit();
}
// Сравнение товаров
if (Core_Array::getRequest('compare')) {
$shop_item_id = intval(Core_Array::getRequest('compare'));
if (Core_Entity::factory('Shop_Item', $shop_item_id)->shop_id == $oShop->id) {
Core_Session::start();
if (isset($_SESSION['hostcmsCompare'][$oShop->id][$shop_item_id])) {
unset($_SESSION['hostcmsCompare'][$oShop->id][$shop_item_id]);
} else {
$_SESSION['hostcmsCompare'][$oShop->id][$shop_item_id] = 1;
}
}
exit();
}
// Если мы находимся на странице товара
if ($Shop_Controller_Show->item) {
$oShop_Item = Core_Entity::factory('Shop_Item', $Shop_Controller_Show->item);
// Текущий элемент
$cur_elem = $Shop_Controller_Show->item;
// Текущая группа
$cur_group = $oShop_Item->shop_group_id;
$shop_id = $oShop->id;
// SELECT * FROM shop_items WHERE shop_items.id < $cur_elem ORDER BY shop_items.id DESC LIMIT 1
$oCore_QueryBuilder_Select = Core_QueryBuilder::select()
->select('shop_items.path')
->from('shop_items')
->open()
->where('shop_items.id', '<', $cur_elem)
->setAnd()
->where('shop_items.shop_group_id', '=', $cur_group)
->setAnd()
->where('shop_items.shop_id', '=', $shop_id)
->setAnd()
->where('shop_items.deleted', '=', '0')
->close()
->clearOrderBy()
->orderBy('id', 'DESC')
->limit(1);
$prev = $oCore_QueryBuilder_Select->execute()->asAssoc()->current();
$prev = $prev['path'];
// SELECT * FROM shop_items WHERE shop_items.id > $cur_elem ORDER BY shop_items.id LIMIT 1
$oCore_QueryBuilder_Select = Core_QueryBuilder::select()
->select('shop_items.path')
->from('shop_items')
->open()
->where('shop_items.id', '>', $cur_elem)
->setAnd()
->where('shop_items.shop_group_id', '=', $cur_group)
->setAnd()
->where('shop_items.shop_id', '=', $shop_id)
->setAnd()
->where('shop_items.deleted', '=', '0')
->close()
->clearOrderBy()
->orderBy('id')
->limit(1);
$next = $oCore_QueryBuilder_Select->execute()->asAssoc()->current();
$next = $next ['path'];
$Shop_Controller_Show
->addEntity(Core::factory('Core_Xml_Entity')
->name('neighboring_items')
->addEntity(Core::factory('Core_Xml_Entity')->name('prev_item')->value($prev))
->addEntity(Core::factory('Core_Xml_Entity')->name('next_item')->value($next))
);
}
// Смотреть товары
if ($Shop_Controller_Show->item) {
   $view_item_id = $Shop_Controller_Show->item;
   if (Core_Entity::factory('Shop_Item', $view_item_id)->shop_id == $oShop->id) {
      Core_Session::start();
      if (isset($_SESSION['hostcmsViewed'][$oShop->id]) && in_array($view_item_id, $_SESSION['hostcmsViewed'][$oShop->id])) {
         unset($_SESSION['hostcmsViewed'][$oShop->id][
            array_search($view_item_id, $_SESSION['hostcmsViewed'][$oShop->id])
         ]);
      } else {
         $_SESSION['hostcmsViewed'][$oShop->id][] = $view_item_id;
      }
   }
}
// Текстовая информация для указания номера страницы, например "страница"
$pageName = Core_Array::get(Core_Page::instance()->libParams, 'page')
? Core_Array::get(Core_Page::instance()->libParams, 'page')
: 'страница';
// Разделитель в заголовке страницы
$pageSeparator = Core_Array::get(Core_Page::instance()->libParams, 'separator')
? Core_Page::instance()->libParams['separator']
: ' | ';
if ($Shop_Controller_Show->group) {
$oShop_Group = Core_Entity::factory('Shop_Group', $Shop_Controller_Show->group);
Core_Page::instance()->title($oShop_Group->seo_title != ''
? $oShop_Group->seo_title
: $oShop_Group->name);
Core_Page::instance()->description($oShop_Group->seo_description != ''
? $oShop_Group->seo_description
: $oShop_Group->name);
Core_Page::instance()->keywords($oShop_Group->seo_keywords != ''
? $oShop_Group->seo_keywords
: $oShop_Group->name);
}
if ($Shop_Controller_Show->item) {
$oShop_Item = Core_Entity::factory('Shop_Item', $Shop_Controller_Show->item);
Core_Page::instance()->title($oShop_Item->seo_title != ''
? $oShop_Item->seo_title
: $oShop_Item->name);
Core_Page::instance()->description($oShop_Item->seo_description != ''
? $oShop_Item->seo_description
: $oShop_Item->name);
Core_Page::instance()->keywords($oShop_Item->seo_keywords != ''
? $oShop_Item->seo_keywords
: $oShop_Item->name);
}
Core_Page::instance()->object = $Shop_Controller_Show;
#
Re: Показ схожих информационных элементов на основе меток
XSL-шаблон

<?xml version="1.0" encoding="utf-8"?><!DOCTYPE xsl:stylesheet>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:hostcms="http://www.hostcms.ru/" exclude-result-prefixes="hostcms">
<xsl:output xmlns="http://www.w3.org/TR/xhtml1/strict" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" encoding="utf-8" indent="yes" method="html" omit-xml-declaration="no" version="1.0" media-type="text/xml"/>
<xslecimal-format name="my" decimal-separator="," grouping-separator=" "/>
<xsl:template match="/shop">
<xsl:apply-templates select="shop_item"/>
<xsl:apply-templates select="/shop/samenews/shop_item"/>

<div class="col-xs-6 col-sm-4 col-md-3">
<a rel="tag" href="{dir}{image_large}" title="Увеличить фото"><xsl:choose><xsl:when test="image_small != ''">
<img src="{dir}{image_small}" alt="{name}" class="img-thumbnail" /></xsl:when></xsl:choose></a>
<h5 class="bold"><xsl:value-of select="format-number(price, '### ##0', 'my')"/><xsl:text> </xsl:text><xsl:value-of select="currency" /><xsl:text> </xsl:text></h5>
<a href="{url}" title="Перейти в проект" hostcms:id="{@id}" hostcms:field="name" hostcms:entity="shop_item">
<xsl:value-of disable-output-escaping="yes" select="name"/></a></div>

</xsl:template>
<xsl:template match="shop_item">
<xsl:variable name="prev_item" select="/shop/neighboring_items/prev_item"/>
<xsl:variable name="next_item" select="/shop/neighboring_items/next_item"/>
<xsl:variable name="link_path" select="/shop/shop_group/url"/>

<ul class="pager">
<xsl:choose><xsl:when test="$prev_item != ''">
<li><a href="../{$prev_item}/">← Предыдущая</a></li></xsl:when><xsl:otherwise></xsl:otherwise></xsl:choose>
<xsl:choose><xsl:when test="$next_item != ''">
<li><a href="../{$next_item}/">Следующая →</a></li></xsl:when><xsl:otherwise></xsl:otherwise></xsl:choose>
<!--<div class="clearfix"></div>-->
</ul>

<h1 hostcms:id="{@id}" hostcms:field="name" hostcms:entity="shop_item"><xsl:value-of disable-output-escaping="yes" select="name"/></h1>
<xsl:variable name="group" select="/shop/group"/>
<xsl:if test="/shop/message/node()">
<xsl:value-of disable-output-escaping="yes" select="/shop/message"/>
</xsl:if>
<!-- Цена товара -->
<h5 class="bold"><xsl:if test="price != 0">Цена:
<xsl:value-of select="format-number(price, '### ##0', 'my')"/><xsl:text> </xsl:text><xsl:value-of select="currency" /><xsl:text> </xsl:text>
<!-- Если цена со скидкой - выводим её -->
<xsl:if test="price_tax != price"><span class="oldPrice">
<xsl:value-of select="format-number(price_tax, '### ##0', 'my')"/><xsl:text> </xsl:text><xsl:value-of select="currency" />
</span><xsl:text> </xsl:text></xsl:if>
</xsl:if></h5>
<!-- Изображение для товара, если есть
<div class="gallery">
<div class="col-xs-6 col-sm-4 col-md-3">
<a rel="tag" href="{dir}{image_large}" title="{name}" class="img_box">
<img src="{dir}{image_small}" alt="{name}" class="img-thumbnail" /></a>
</div>
</div>
-->
<!-- Описание товара -->
<xsl:if test="description != ''">
<!--<div hostcms:id="{@id}" hostcms:field="description" hostcms:entity="shop_item" hostcms:type="wysiwyg">-->
<xsl:value-of disable-output-escaping="yes" select="description" />
<!--</div>-->
</xsl:if>
<!-- Текст товара -->
<xsl:if test="text != ''">
<div hostcms:id="{@id}" hostcms:field="text" hostcms:entity="shop_item" hostcms:type="wysiwyg"><xsl:value-of disable-output-escaping="yes" select="text"/></div>
</xsl:if>
<!-- Если указано отображать комментарии -->
<xsl:if test="/shop/show_comments/node() and /shop/show_comments = 1">
<!-- Отображение комментариев  -->
<xsl:if test="count(comment) &gt; 0">
<p class="h1"><a name="comments"></a>Комментарии</p>
<xsl:apply-templates select="comment"/>
</xsl:if>
</xsl:if>

<p class="both h3 bg-prim m-b">Похожие изделия - проекты</p>

<!--
<xsl:template match="/shop">
<xsl:apply-templates select="shop_item"/>
<xsl:apply-templates select="/shop/samenews/shop_item"/>
<div class="gallery"><xsl:template match="shop_item"></div>


<div class="col-xs-6 col-sm-4 col-md-3">
<a rel="tag" href="{dir}{image_large}" title="Увеличить фото"><xsl:choose><xsl:when test="image_small != ''">
<img src="{dir}{image_small}" alt="{name}" class="img-thumbnail" /></xsl:when></xsl:choose></a>
<h5 class="bold"><xsl:value-of select="format-number(price, '### ##0', 'my')"/><xsl:text> </xsl:text><xsl:value-of select="currency" /><xsl:text> </xsl:text></h5>
<a href="{url}" title="Перейти в проект" hostcms:id="{@id}" hostcms:field="name" hostcms:entity="shop_item">
<xsl:value-of disable-output-escaping="yes" select="name"/></a></div>
</xsl:template>
-->

<!-- Тэги для информационного элемента -->
<p class="tags both">
<xsl:if test="count(tag) &gt; 0">
<span class="octicon octicon-tag"></span><span><xsl:apply-templates select="tag"/></span>
</xsl:if>
</p>

</xsl:template>
<!-- Вывод строки со значением свойства -->
<xsl:template match="property_value">
<xsl:if test="value/node() and value != '' or file/node() and file != ''">
<div class="shop_property">
<xsl:variable name="property_id" select="property_id" />
<xsl:variable name="property" select="/shop/shop_item_properties//property[@id=$property_id]" />
<xsl:value-of disable-output-escaping="yes" select="$property/name"/><xsl:text>: </xsl:text>
<span><xsl:choose>
<xsl:when test="$property/type = 2">
<a href="{../dir}{file}" target="_blank"><xsl:value-of disable-output-escaping="yes" select="file_name"/></a>
</xsl:when>
<xsl:when test="$property/type = 7">
<input type="checkbox" disabled="disabled">
<xsl:if test="value = 1">
<xsl:attribute name="checked">checked</xsl:attribute>
</xsl:if>
</input>
</xsl:when>
<xsl:otherwise>
<xsl:value-of disable-output-escaping="yes" select="value"/>
</xsl:otherwise>
</xsl:choose></span>
</div>
</xsl:if>
</xsl:template>

<!-- Метки -->
<xsl:template match="tag"><a href="{/shop/url}tag/{urlencode}/" class="tag"><xsl:value-of select="name"/></a>
<xsl:if test="position() != last()"><xsl:text>, </xsl:text></xsl:if>
</xsl:template>
<!-- Шаблон для модификаций -->
<xsl:template match="modifications/shop_item">
<li>
<!-- Название модификации -->
<a href="{url}"><xsl:value-of disable-output-escaping="yes" select="name"/></a>,
<!-- Цена модификации -->
<xsl:value-of select="price"/><xsl:text> </xsl:text><xsl:value-of disable-output-escaping="yes" select="currency"/>
</li>
</xsl:template>
<!-- Шаблон для сопутствующих товаров -->
<xsl:template match="associated/shop_item">
<li>
<!-- Название сопутствующего товара -->
<a href="{url}"><xsl:value-of disable-output-escaping="yes" select="name"/></a>,
<!-- Цена сопутствующего товара -->
<xsl:value-of select="price"/><xsl:text> </xsl:text><xsl:value-of disable-output-escaping="yes" select="currency"/>
</li>
</xsl:template>
<!-- Вывод рейтинга -->
<xsl:template name="show_average_grade">
<xsl:param name="grade" select="0"/>
<xsl:param name="const_grade" select="0"/>
<!-- Чтобы избежать зацикливания -->
<xsl:variable name="current_grade" select="$grade * 1"/>
<xsl:choose>
<!-- Если число целое -->
<xsl:when test="floor($current_grade) = $current_grade and not($const_grade &gt; ceiling($current_grade))">
<xsl:if test="$current_grade - 1 &gt; 0">
<xsl:call-template name="show_average_grade">
<xsl:with-param name="grade" select="$current_grade - 1"/>
<xsl:with-param name="const_grade" select="$const_grade - 1"/>
</xsl:call-template>
</xsl:if>
<xsl:if test="$current_grade != 0">
<img src="/images/star-full.png"/>
</xsl:if>
</xsl:when>
<xsl:when test="$current_grade != 0 and not($const_grade &gt; ceiling($current_grade))">
<xsl:if test="$current_grade - 0.5 &gt; 0">
<xsl:call-template name="show_average_grade">
<xsl:with-param name="grade" select="$current_grade - 0.5"/>
<xsl:with-param name="const_grade" select="$const_grade - 1"/>
</xsl:call-template>
</xsl:if>
<img src="/images/star-half.png"/>
</xsl:when>
<!-- Выводим серые звездочки, пока текущая позиция не дойдет то значения, увеличенного до целого -->
<xsl:otherwise>
<xsl:call-template name="show_average_grade">
<xsl:with-param name="grade" select="$current_grade"/>
<xsl:with-param name="const_grade" select="$const_grade - 1"/>
</xsl:call-template>
<img src="/images/star-empty.png"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- Шаблон для вывода звездочек (оценки) -->
<xsl:template name="for">
<xsl:param name="i" select="0"/>
<xsl:param name="n"/>
<input type="radio" name="shop_grade" value="{$i}" id="id_shop_grade_{$i}">
<xsl:if test="/shop/shop_grade = $i">
<xsl:attribute name="checked"></xsl:attribute>
</xsl:if>
</input><xsl:text> </xsl:text>
<label for="id_shop_grade_{$i}">
<xsl:call-template name="show_average_grade">
<xsl:with-param name="grade" select="$i"/>
<xsl:with-param name="const_grade" select="5"/>
</xsl:call-template>
</label>
<br/>
<xsl:if test="$n &gt; $i and $n &gt; 1">
<xsl:call-template name="for">
<xsl:with-param name="i" select="$i + 1"/>
<xsl:with-param name="n" select="$n"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
<!-- Отображение комментариев -->
<xsl:template match="comment">
<!-- Отображаем комментарий, если задан текст или тема комментария -->
<xsl:if test="text != '' or subject != ''">
<a name="comment{@id}"></a>
<div class="comment" id="comment{@id}">
<xsl:if test="subject != ''">
<div class="subject" hostcms:id="{@id}" hostcms:field="subject" hostcms:entity="comment"><xsl:value-of select="subject"/></div>
</xsl:if>
<div hostcms:id="{@id}" hostcms:field="text" hostcms:entity="comment" hostcms:type="wysiwyg"><xsl:value-of select="text" disable-output-escaping="yes"/></div>
<p class="tags">
<!-- Оценка комментария -->
<xsl:if test="grade != 0">
<span><xsl:call-template name="show_average_grade">
<xsl:with-param name="grade" select="grade"/>
<xsl:with-param name="const_grade" select="5"/>
</xsl:call-template></span>
</xsl:if>
<img src="/images/user.png" />
<xsl:choose>
<!-- Комментарий добавил авторизированный пользователь -->
<xsl:when test="count(siteuser) &gt; 0">
<span><a href="/users/info/{siteuser/login}/"><xsl:value-of select="siteuser/login"/></a></span>
</xsl:when>
<!-- Комментарй добавил неавторизированный пользователь -->
<xsl:otherwise>
<span><xsl:value-of select="author" /></span>
</xsl:otherwise>
</xsl:choose>
<img src="/images/calendar.png" /> <span><xsl:value-of select="datetime"/></span>
<xsl:if test="/shop/show_add_comments/node()
and ((/shop/show_add_comments = 1 and /shop/siteuser_id > 0)
or /shop/show_add_comments = 2)">
<span class="red" onclick="$('.comment_reply').hide('slow');$('#cr_{@id}').toggle('slow')">ответить</span></xsl:if>
<span class="red"><a href="{/shop/shop_item/url}#comment{@id}" title="Ссылка на комментарий">#</a></span>
</p>
</div>
<!-- Отображаем только авторизированным пользователям -->
<xsl:if test="/shop/show_add_comments/node() and ((/shop/show_add_comments = 1 and /shop/siteuser_id > 0) or /shop/show_add_comments = 2)">
<div class="comment_reply" id="cr_{@id}">
<xsl:call-template name="AddCommentForm">
<xsl:with-param name="id" select="@id"/>
</xsl:call-template>
</div>
</xsl:if>
<!-- Выбираем дочерние комментарии -->
<xsl:if test="count(comment)">
<div class="comment_sub">
<xsl:apply-templates select="comment"/>
</div>
</xsl:if>
</xsl:if>
</xsl:template>
<!-- Шаблон вывода добавления комментария -->
<xsl:template match="shop_discount"><div class="shop_discount"><xsl:value-of disable-output-escaping="yes" select="name"/><xsl:text> </xsl:text><span><xsl:value-of select="percent"/>%</span></div></xsl:template><xsl:template match="shop_group" mode="breadCrumbs"><xsl:variable name="parent_id" select="parent_id"/><xsl:apply-templates select="//shop_group[@id=$parent_id]" mode="breadCrumbs"/><xsl:if test="parent_id=0"><a href="{/shop/url}" hostcms:id="{/shop/@id}" hostcms:field="name" hostcms:entity="shop"><xsl:value-of select="/shop/name"/></a></xsl:if><span><xsl:text> → </xsl:text></span><a href="{url}" hostcms:id="{@id}" hostcms:field="name" hostcms:entity="shop_group"><xsl:value-of select="name"/></a></xsl:template><xsl:template name="declension"><xsl:param name="number" select="number"/><xsl:variable name="nominative">

</xsl:variable><xsl:variable name="genitive_singular"></xsl:variable><xsl:variable name="genitive_plural"></xsl:variable><xsl:variable name="last_digit"><xsl:value-of select="$number mod 10"/></xsl:variable><xsl:variable name="last_two_digits"><xsl:value-of select="$number mod 100"/></xsl:variable><xsl:choose><xsl:when test="$last_digit = 1 and $last_two_digits != 11"><xsl:value-of select="$nominative"/></xsl:when><xsl:when test="$last_digit = 2 and $last_two_digits != 12or $last_digit = 3 and $last_two_digits != 13or $last_digit = 4 and $last_two_digits != 14"><xsl:value-of select="$genitive_singular"/></xsl:when><xsl:otherwise><xsl:value-of select="$genitive_plural"/></xsl:otherwise></xsl:choose></xsl:template></xsl:stylesheet>
#
Re: Показ схожих информационных элементов на основе меток
1. вставлять код нужно после parseUrl(), а еще лучше как написано "Код вносится в типовую дин. страницу перед показом контроллера" а не в "Настройка типовой дин. страницы"
2.
$oShop_Item = Core_Entity::factory('Shop_Item', $Shop_Controller_Show->item);
$oTag_Shop_Items = $oShop_Item->Tag_Shop_Items->findAll();

// Минимальное количество тегов для совпадения.
$iSameTags = 2;

$aTagIds = array();
foreach($oTag_Shop_Items as $oTag_Shop_Item)
{
   $aTagIds[] = $oTag_Shop_Item->tag_id;
}

if (count($aTagIds))
{
   $oSameTag_Shop_Items = Core_Entity::factory('Tag_Shop_Item');
   $oSameTag_Shop_Items->queryBuilder()
      ->select('tag_shop_items.*')
      ->where('tag_id', 'IN', $aTagIds)
      ->where('tag_shop_items.shop_item_id', '!=', $oShop_Item->id)
      ->join('shop_items', 'tag_shop_items.shop_item_id', '=', 'shop_items.id')
      ->join('shops', 'shop_items.shop_id', '=', 'shops.id')
      ->where('shops.site_id', '=', CURRENT_SITE)
      ->groupBy('shop_items.id')
      ->having('COUNT(tag_id)', '>=', $iSameTags)
      ->clearOrderBy()
      ->orderBy('RAND()')
      ->limit(5);

   $aSameTag_Shop_Items = $oSameTag_Shop_Items->findAll();

   $oXmlSamenews = Core::factory('Core_Xml_Entity')->name('samenews');
   $Shop_Controller_Show->addEntity($oXmlSamenews);

   foreach($aSameTag_Shop_Items as $oSameTag_Shop_Item)
   {
      $oXmlSamenews->addEntity(
         $oSameTag_Shop_Item->Shop_Item->clearEntities()
      );
   }
}
www.morozovpimnev.ru - создание, поддержка и продвижение сайтов | Наш канал https://asmp.su/channel
Авторизация