Example #1
0
 public function getToysFromCategoryAction()
 {
     $categoryId = $this->_getParam('categoryId');
     $t = $this->_getParam('t');
     $Category = new Category();
     $cur_category = $Category->get($categoryId);
     if (!$cur_category) {
         throw new Zend_Controller_Action_Exception('Такой категории у нас нет', 404);
     }
     $Product = new Product();
     if (trim($cur_category['children']) == $categoryId) {
         $list_params = $this->get_list_params();
         $options = array('page' => $list_params['pageNumber'], 'perPage' => 20 * $list_params['pl'], 'order' => $list_params['order'], 'orderby' => $list_params['orderby']);
         if ($t) {
             $options['t'] = $t;
         }
         //$this->view->toys = $Product->get_products_by_category($categoryId,$options,$rPaginator);
         $Product->get_products_by_category($categoryId, $options, $rPaginator);
         $rPaginator->setPageRange(20);
         $this->view->toys = $rPaginator->getCurrentItems()->toArray();
         $this->view->paginator = $rPaginator;
         $this->view->h1 = $cur_category['name'];
         $this->view->descr = ' Категория ' . $cur_category['name'] . '.';
         $this->view->order = $list_params['order'];
         $this->view->orderby = $list_params['orderby'];
         $this->view->ar_order = $list_params['ar_order'];
         $this->view->pl = $list_params['pl'];
         $this->view->list_type = 'from_category';
         $this->view->show = $list_params['show'];
     } else {
         $this->view->toys = $Product->get_new_products_by_category($cur_category['children'], 10);
         $this->view->h1 = "Новинки - " . $cur_category['name'];
         $this->view->descr = ' Новинки из категории ' . $cur_category['name'] . '.';
         $this->view->list_type = 'top_new';
         $this->view->show = 'list';
     }
     if (count($this->view->toys) == 1) {
         $this->_forward('detail', null, null, array('toy_id' => $this->view->toys[0]['id']));
     } else {
         if ($this->view->show == 'list') {
             $this->_helper->viewRenderer('list-toys');
         } else {
             $this->_helper->viewRenderer('grid-toys');
         }
     }
     $this->set_layout_vars();
 }