public function indexAction()
 {
     $select = $this->_categoriesModelMapper->getDbTable()->select()->where('parent_id = ?', 0)->where('active = ?', 1)->where('generate = ?', 1)->order('sorting ASC');
     $categories = $this->_categoriesModelMapper->fetchAll($select);
     $this->view->categories = $categories;
     $request = $this->getRequest();
     $category_id = $request->getParam('category_id');
     $category = $this->_categoriesModelMapper->find($category_id, new Catalog_Model_Categories());
     $expArrayCsv = $this->expArrayForCsv($category_id);
     $this->fileToCsv('./tmp/' . $category->getPath() . '.csv', $expArrayCsv);
     $this->view->array = $expArrayCsv;
 }
 /**
  * @param $id
  * @return int
  */
 protected function _countSubCategories($id)
 {
     $select = $this->_modelMapper->getDbTable()->select();
     $select->where('parent_id = ?', $id)->order('sorting ASC');
     $entries = $this->_modelMapper->fetchAll($select);
     return count($entries);
 }
 /**
  * @param int $category_id
  * @param int $active
  * @return array
  */
 function GetSubCategories($category_id, $active = 0)
 {
     $categories = new Catalog_Model_Mapper_Categories();
     $select = $categories->getDbTable()->select();
     $select->where('parent_id = ?', $category_id)->where('active != ?', $active)->order('sorting ASC');
     $entries = $categories->fetchAll($select);
     return $entries;
 }
 /**
  * @param $category_id
  * @return array
  */
 public function getSidebarItem($category_id)
 {
     $categories = new Catalog_Model_Mapper_Categories();
     $select = $categories->getDbTable()->select();
     $select->where('parent_id = ?', $category_id)->where('deleted != ?', 1)->order('sorting ASC');
     if (!$this->_auth) {
         $select->where('active != ?', 0);
     }
     $entries = $categories->fetchAll($select);
     return $entries;
 }
 public function init()
 {
     $this->_pagesMapper = new Pages_Model_Mapper_Pages();
     $this->_redirector = $this->_helper->getHelper('Redirector');
     $this->_auth = Zend_Auth::getInstance()->hasIdentity();
     $this->_page = $this->pageModule();
     $this->view->meta_title = !$this->_page->getMetaTitle() ? $this->_page->getTitle() : $this->_page->getMetaTitle();
     $this->view->meta_description = !$this->_page->getMetaDescription() ? 'Альфа-Гидро - Каталог продукции: Гидравлическое оборудование, гидрокомпоненты, рукава высокого давления, шланги, втулки и фитинги, защита для шлангов, БРС, скобы, трубы, соединительная арматура, краны, манометры, уплотнительная техника.' : $this->_page->getMetaDescription();
     $this->view->meta_keywords = !$this->_page->getMetaKeywords() ? 'каталог, оборудование, гидрокомпоненты, РВД, шланги, втулки, фитинги, защита для шлангов, БРС, скобы, трубы, арматура, краны, манометры, уплотнители.' : $this->_page->getMetaKeywords();
     $this->view->adminPath = 'categories';
     $categories = new Catalog_Model_Mapper_Categories();
     $select = $categories->getDbTable()->select();
     $select->where('parent_id = ?', 0)->where('deleted != ?', 1)->order('sorting ASC');
     if (!$this->_auth) {
         $select->where('active != ?', 0);
     }
     $entries = $categories->fetchAll($select);
     $this->view->entries = $entries;
 }
 public function indexAction()
 {
     $fullPath = $this->getFullPath();
     $categories = new Catalog_Model_Mapper_Categories();
     $category = new Catalog_Model_Categories();
     $category = $categories->findByFulPath($fullPath, $category);
     if (is_null($category)) {
         //throw new Zend_Controller_Action_Exception("Страница не найдена", 404);
         $this->forward('view', 'products');
         return;
     }
     if (Zend_Auth::getInstance()->hasIdentity()) {
         $this->_request->setParams(array('dataItem' => array('controller' => 'categories', 'id' => $category->getId(), 'active' => $category->getActive(), 'deleted' => $category->getDeleted())));
     }
     if ($category->getDeleted() === '1') {
         if (!Zend_Auth::getInstance()->hasIdentity()) {
             throw new Zend_Controller_Action_Exception("Страница не найдена", 404);
         }
         $this->_redirector->gotoRouteAndExit(array('module' => 'admin', 'controller' => 'categories', 'action' => 'index', 'parent_id' => $category->getParentId()), 'adminCategoriesEdit', true);
     }
     $current_category_id = $category->getId();
     $this->view->assign('adminPath', 'categories/' . $current_category_id);
     if ($current_category_id !== 0) {
         $jsonRequest = $this->getRequest()->getParam('json');
         if (isset($jsonRequest)) {
             $id = $jsonRequest !== '' ? $jsonRequest : $current_category_id;
             $this->forward('json', 'categories', 'admin', array('id' => $id));
             return;
         }
         $select = $categories->getDbTable()->select();
         $select->where('parent_id = ?', $current_category_id)->where('deleted != ?', 1)->order('sorting ASC');
         if (!$this->_auth) {
             $select->where('active != ?', 0);
         }
         $entries = $categories->fetchAll($select);
         if (empty($entries)) {
             /*$productsMapper = new Catalog_Model_Mapper_Products();
               $select = $productsMapper->getDbTable()->select()->order('sorting ASC');
               $entries = $categories->fetchProductsRel($current_category_id, $select);*/
             $this->view->assign(array('category' => $category));
             $this->forward('index', 'products');
             return;
         }
         $this->view->assign('entries', $entries);
     } else {
         $this->redirect('/catalog/', array('code' => 301));
         return;
     }
     if ($category->getMetaKeywords() != '') {
         $meta_keywords = $category->getMetaKeywords();
     } else {
         $aKeywords = array();
         if (!empty($entries)) {
             foreach ($entries as $entry) {
                 $aKeywords[] = $entry->getName();
             }
         }
         $aKeywords[] = $category->getName();
         $meta_keywords = implode(", ", array_reverse($aKeywords));
     }
     $this->view->assign(array('title' => $category->getName(), 'current_category' => $current_category_id, 'meta_description' => $this->setMetaDescription($category), 'meta_keywords' => strtolower($meta_keywords)));
     if ($category->getActive() === '0' && !Zend_Auth::getInstance()->hasIdentity()) {
         $this->view->assign(array('breadcrumbs' => true, 'sidebar_headers' => true));
         throw new Zend_Controller_Action_Exception("Раздел временно не доступен", 403);
     }
 }