if ($Shop_Controller_Show->item)
{
$oShop = $Shop_Controller_Show->getEntity();
// XML-сущность, к которй будут добавляться товары
$oNewItemsXmlEntity = Core::factory('Core_Xml_Entity')->name('new_items');
// Добавляем XML-сущность контроллеру показа
$Shop_Controller_Show->addEntity($oNewItemsXmlEntity);
$oShop_Items = $oShop->Shop_Items;
$oShop_Items->queryBuilder()
->where('shop_items.active', '=', 1)
->where('shop_items.shop_group_id', '=', $Shop_Controller_Show->group)
->where('shop_items.id', '!=', $Shop_Controller_Show->item)
->limit(5)
->clearOrderBy()
->orderBy('RAND()')
->leftJoin('shop_warehouse_items', 'shop_warehouse_items.shop_item_id', '=', 'shop_items.id')
->groupBy('shop_items.id')
->having('SUM(shop_warehouse_items.count)', '>', 0);
$aShop_Items = $oShop_Items->findAll(FALSE);
foreach($aShop_Items as $oShop_Item)
{
$oNewItemsXmlEntity->addEntity(
$oShop_Item->clearEntities()
);
}
}