'sorter'); public function preDispatch(&$items) { if (count($this->getRestParams())) { foreach ($items as $k => $v) { if ($v['type'] == 'HtmlBlock_') { unset($items[$k]); } } } return $this; } public function exec() { $params = $this->getRestParams(); $paramsCount = count($params); $productType = $this->getConfig('type'); if ($paramsCount) { if (1 == $paramsCount && ctype_digit($params[0])) { $this->dataObj->setPrimaryKey(intval($params[0])); $this->_data = $this->dataObj->getData(); if (!$this->_data || $this->_data['idProductType'] != $productType) { $this->doc->display404(); } $this->_defaultAction = 'view'; } else { $this->doc->display404(); } } else { if (!empty($productType)) { $this->dataObj->addFilter(array('idProductType' => (int) $productType)); } } return parent::exec(); } protected function _doView() { $item = $this->_data; $this->doc->setOption('image', $item['image']); $this->doc->setHeader($item['name']); $item['tpl'] = $this->getTemplate('view.tpl'); $this->_addItem($item); return $this; } public function getSideBlockItem() { $item = array(); $list = $this->dataObj->getList(array('limit' => self::SMALL_LIST_COUNT, 'order' => 'sorter', 'where' => '`featured` = "y"')); if (!empty($list)) { $productPages = Qs_SiteMap::find(null, array('type' => 'Product_')); $productTypeViewAliases = array(); foreach ($productPages as $page) { foreach ($page['items'] as $pageItem) { if ($pageItem['type'] == 'Product_') { $productTypeViewAliases[$pageItem['config']['type']] = $page['fullAlias']; } } } $item['list'] = $list; $item['viewAliases'] = $productTypeViewAliases; $item['tpl'] = 'Product/small-list.tpl'; } return $item; } public function fillConfigForm(Qs_Form $form) { $form->addElement( 'select', 'type', array( 'label' => 'Product Type', 'multiOptions' => $this->dataObj->getProductType4Select() ) ); return $this; } }