/** * Build array combining product categories, families and Custom Pages. * * @return array */ public function getMenuTree() { $categoryTree = Category::GetTree(); $extraTopLevelItems = CustomPage::GetTree(); // Whether the families (aka. manufacturers) are displayed the product menu. // ENABLE_FAMILIES: // 0 => No families in the product menu. // 1 => Separate menu item at bottom of product menu. // 2 => Separate menu item at top of product menu. // 3 => Blended into the top level of the menu. // if (CPropertyValue::ensureInteger(Yii::app()->params['ENABLE_FAMILIES']) > 0) { $familyTree = Family::GetTree(); if (CPropertyValue::ensureInteger(Yii::app()->params['ENABLE_FAMILIES']) === 3) { $extraTopLevelItems += $familyTree; } } // The behaviour varies here because OnSite customers are able to // configure the menu_position of their categories. A more thorough // solution might modify the menu code to return the menu_position for // each menu item for sorting, however Categories should already be // sorted by menu_position. if (CPropertyValue::ensureInteger(Yii::app()->params['LIGHTSPEED_CLOUD']) !== 0) { // Retail: Sort the entire menu alphabetically. $objTree = $categoryTree + $extraTopLevelItems; ksort($objTree); } else { // OnSite: Only sort the extras alphabetically (categories are // already sorted by menu_position). ksort($extraTopLevelItems); $objTree = $categoryTree + $extraTopLevelItems; } if (CPropertyValue::ensureInteger(Yii::app()->params['ENABLE_FAMILIES']) === 1 || CPropertyValue::ensureInteger(Yii::app()->params['ENABLE_FAMILIES']) === 2) { $familyMenu['families_brands_menu'] = array('text' => CHtml::link(Yii::t('category', Yii::app()->params['ENABLE_FAMILIES_MENU_LABEL']), $this->createUrl("search/browse", array('brand' => '*'))), 'label' => Yii::t('category', Yii::app()->params['ENABLE_FAMILIES_MENU_LABEL']), 'link' => $this->createUrl("search/browse", array('brand' => '*')), 'url' => $this->createUrl("search/browse", array('brand' => '*')), 'id' => 0, 'child_count' => count($familyTree), 'hasChildren' => 1, 'children' => $familyTree, 'items' => $familyTree); if (CPropertyValue::ensureInteger(Yii::app()->params['ENABLE_FAMILIES']) === 1) { // The manufacturers menu is at the bottom. $objTree = $objTree + $familyMenu; } elseif (CPropertyValue::ensureInteger(Yii::app()->params['ENABLE_FAMILIES']) === 2) { // The manufacturers menu is at the top. $objTree = $familyMenu + $objTree; } } $this->_objFullTree = $objTree; return $this->_objFullTree; }