// В корне выводим из всех групп
if ($Shop_Controller_Show->group == 0)
{
class my_Structure_Controller_Show extends Structure_Controller_Show
{
protected function _addShopGroups($parentObject, $oShop, $level = 0)
{
$dateTime = Core_Date::timestamp2sql(time());
$oShop_Groups = $oShop->Shop_Groups;
$oShop_Groups->queryBuilder()
->where('shop_groups.siteuser_group_id', 'IN', $this->_aSiteuserGroups)
->where('shop_groups.active', '=', 1)
->clearOrderBy();
switch ($oShop->groups_sorting_direction)
{
case 0:
$groups_sorting_direction = 'ASC';
break;
case 1:
default:
}
// Определяем поле сортировки групп
switch ($oShop->groups_sorting_field)
{
case 0:
$oShop_Groups
->queryBuilder()
->orderBy('shop_groups.name', $groups_sorting_direction);
break;
case 1:
default:
$oShop_Groups
->queryBuilder()
->orderBy('shop_groups.sorting', $groups_sorting_direction);
break;
}
if ($level > 1) {
$oShop_Groups
->queryBuilder()
->clearOrderBy()
->orderBy('RAND()');
}
$this->_aShop_Groups = array();
Core_Event::notify(get_class($this) . '.onBeforeFindShopGroups', $this, array($oShop_Groups, $parentObject, $oShop));
$aShop_Groups = $oShop_Groups->findAll();
foreach ($aShop_Groups as $oShop_Group)
{
$this->_aShop_Groups[$oShop_Group->parent_id][] = $oShop_Group;
}
// Shop's items
if ($this->showShopItems)
{
$oShop_Items = $oShop->Shop_Items;
$oShop_Items->queryBuilder()
->select('shop_items.*')
->open()
->where('shop_items.start_datetime', '<', $dateTime)
->setOr()
->where('shop_items.start_datetime', '=', '0000-00-00 00:00:00')
->close()
->setAnd()
->open()
->where('shop_items.end_datetime', '>', $dateTime)
->setOr()
->where('shop_items.end_datetime', '=', '0000-00-00 00:00:00')
->close()
->where('shop_items.siteuser_group_id', 'IN', $this->_aSiteuserGroups)
->where('shop_items.modification_id', '=', 0)
->clearOrderBy();
switch ($oShop->items_sorting_direction)
{
case 1:
$items_sorting_direction = 'DESC';
break;
case 0:
default:
$items_sorting_direction = 'ASC';
}
// Определяем поле сортировки информационных элементов
switch ($oShop->items_sorting_field)
{
case 1:
$oShop_Items
->queryBuilder()
->orderBy('shop_items.name', $items_sorting_direction)
->orderBy('shop_items.sorting', $items_sorting_direction);
break;
case 2:
$oShop_Items
->queryBuilder()
->orderBy('shop_items.sorting', $items_sorting_direction)
->orderBy('shop_items.name', $items_sorting_direction);
break;
case 0:
default:
$oShop_Items
->queryBuilder()
->orderBy('shop_items.datetime', $items_sorting_direction)
->orderBy('shop_items.sorting', $items_sorting_direction);
}
$oShop_Items
->queryBuilder()
->clearOrderBy()
->orderBy('RAND()');
$this->_aShop_Items = array();
Core_Event::notify(get_class($this) . '.onBeforeFindShopItems', $this, array($oShop_Items, $parentObject, $oShop));
$aShop_Items = $oShop_Items->findAll();
foreach ($aShop_Items as $oShop_Item)
{
$this->_aShop_Items[$oShop_Item->shop_group_id][] = $oShop_Item;
}
}
$this->_addShopGroupsByParentId(0, $parentObject);
}
};
$Structure_Controller_Show = new my_Structure_Controller_Show(
Core_Entity::factory('Site', 3)
);
$Structure_Controller_Show
->showShopGroups(true)
->showShopItems(true)
->parentId('134')
->xsl(
Core_Entity::factory('Xsl')->getByName('породукциякорень')
)
->show();
вот так вот сделал,... пробовал проверку делать на $level >1, чтоб на высшем уровне у меня группы выбирались со стандартной сортировкой, а вложенные уже выбирались со случайной, но как-то у меня ничего хорошего не вышло.