public function deleteAction()
 {
     $productId = $this->_request->getParam('id');
     $category = $this->_modelMapper->findCategoryRel($productId, new Catalog_Model_Categories());
     //$this->setRedirectUrl('/catalog/'.$category->getFullPath());
     $this->setRedirectUrl($this->_request->getParam('currentUrl'));
     $this->clearCache('CatalogProductsList');
     parent::deleteAction();
 }
 function getCategoryProduct($id)
 {
     $productsMapper = new Catalog_Model_Mapper_Products();
     $category = $productsMapper->findCategoryRel($id, new Catalog_Model_Categories());
     return $category;
 }
 /**
  * @throws Zend_Controller_Action_Exception
  *
  */
 public function viewAction()
 {
     $fullPath = $this->getFullPath();
     $products = new Catalog_Model_Mapper_Products();
     $product = new Catalog_Model_Products();
     $product = $products->findByFulPath($fullPath, $product);
     if (is_null($product)) {
         throw new Zend_Controller_Action_Exception("Страница не найдена", 404);
     }
     if (!is_null($this->getRequest()->getParam('json')) && Zend_Auth::getInstance()->hasIdentity()) {
         $this->forward('json', 'products', 'admin', array('id' => $product->getId()));
         return;
     }
     $categoryRel = $products->findCategoryRel($product->getId(), new Catalog_Model_Categories());
     $this->setCurrentCategory($categoryRel);
     if ($product->getDeleted() != '0') {
         if (!Zend_Auth::getInstance()->hasIdentity()) {
             throw new Zend_Controller_Action_Exception("Страница не найдена", 404);
         }
         $this->_redirector->gotoRouteAndExit(array('module' => 'admin', 'controller' => 'categories', 'action' => 'list', 'id' => $categoryRel->getId()), 'adminEdit', true);
     }
     $this->view->draftImage = $product->getDraft();
     if (!is_null($product->getAImages())) {
         $draftImages = unserialize($product->getAImages());
         if (!empty($draftImages)) {
             $this->view->draftImage = $draftImages[0];
         }
     }
     $productsParams = new Catalog_Model_Mapper_ProductParams();
     $select = $productsParams->getDbTable()->select()->order('order ASC');
     $productProrerty = $products->findProductParams($product->getId(), $select);
     if (!empty($productProrerty)) {
         $this->view->productProperty = $productProrerty;
     }
     $subproducts = new Catalog_Model_Mapper_Subproducts();
     $select = $subproducts->getDbTable()->select()->where('deleted != ?', 1)->order('order ASC');
     $modifications = $products->findSubproductsRel($product->getId(), $select);
     if (!empty($modifications)) {
         $this->view->modificationsTableValues = $this->modificationsTableValues($modifications);
         $this->view->modifications = $modifications;
     }
     $subproductParams = new Catalog_Model_Mapper_SubproductParams();
     $select = $subproductParams->getDbTable()->select()->order('order ASC');
     $subproductProperty = $products->findSubproductParams($product->getId(), $select);
     if (!empty($subproductProperty)) {
         $this->view->assign('subproductProperty', $subproductProperty);
     }
     if ($product->getMetaDescription() != '') {
         $meta_description = $product->getMetaDescription();
     } else {
         $categoryMapper = new Catalog_Model_Mapper_Categories();
         $parentCategories = $categoryMapper->fetchTreeParentCategories($categoryRel->getId());
         $aDescription = array();
         $aDescription[] = $product->getName();
         if (!empty($parentCategories)) {
             foreach ($parentCategories as $parentCategory) {
                 $aDescription[] = $parentCategory->name;
             }
         }
         $aDescription[] = 'Альфа-Гидро - Каталог продукции';
         $meta_description = implode(", ", array_reverse($aDescription));
     }
     if ($product->getMetaKeywords() != '') {
         $meta_keywords = $product->getMetaKeywords();
     } else {
         $aKeywords = array();
         if (!empty($modifications)) {
             /**@var $modification Catalog_Model_Subproducts*/
             foreach ($modifications as $modification) {
                 $sku = $modification->getSku();
                 $aKeywords[] = str_replace('A', '', $sku);
                 $aKeywords[] = str_replace(' ', '', $sku);
                 $aKeywords[] = str_replace(array(' ', 'A'), '', $sku);
             }
         }
         $aKeywords[] = $product->getSku();
         $aKeywords[] = $product->getName();
         $meta_keywords = implode(", ", array_reverse($aKeywords));
     }
     $this->view->assign(array('current_category' => $categoryRel->getId(), 'product' => $product, 'title' => $this->transformSku($product->getSku()), 'secondaryHeader' => $product->getName(), 'adminPath' => 'categories/list/' . $categoryRel->getId(), 'meta_description' => $meta_description, 'meta_keywords' => $meta_keywords));
     if ($product->getActive() != '1' && !Zend_Auth::getInstance()->hasIdentity()) {
         $this->view->assign(array('breadcrumbs' => true, 'sidebar_headers' => true));
         throw new Zend_Controller_Action_Exception("Товар временно не доступен", 403);
     }
     if (Zend_Auth::getInstance()->hasIdentity()) {
         $this->_request->setParams(array('dataItem' => array('controller' => 'products', 'id' => $product->getId(), 'active' => $product->getActive(), 'deleted' => $product->getDeleted())));
     }
 }