/** * Ajax Data */ public function generateCategoriesFullPathAction() { $categories = new Catalog_Model_Mapper_Categories(); $freePathCategories = $categories->fetchFreeRowColumn('full_path'); foreach ($freePathCategories as $category) { $id = $category->id; $fullPath = $categories->generateFullPath($id); $category->fullPath = $fullPath; //if($this->_validateColumn($category->fullPath, 'categories', 'full_path')){ $mapper = new Catalog_Model_Mapper_Categories(); $mapper->save($category); //} } $this->view->entries = $categories->fetchFreeRowColumn('full_path'); }
public function editAction() { $categoryId = $this->_request->getParam('id'); if (is_null($categoryId)) { $this->_redirector->gotoSimpleAndExit('index'); } $category = $this->_modelMapper->find($categoryId, new Catalog_Model_Categories()); if (is_null($category)) { throw new Zend_Controller_Action_Exception("Страница не найдена", 404); } $parentCategoryId = $category->getParentId(); if ($this->_request->isPost()) { //Zend_Debug::dump($this->_request->getParams()); $url = $this->_request->getParam('currentUrl'); if ($this->_request->getParam('dataFormCategory')) { $dataCategory = $this->_request->getParam('dataFormCategory'); $category->setOptions($dataCategory); $category->setModDate(date("Y-m-d H:i:s")); $context_html = Michelf\MarkdownExtra::defaultTransform($dataCategory['contentMarkdown']); $category->setContentHtml($context_html); $parentFullPath = $this->_modelMapper->generateFullPath($dataCategory['parentId']); $fullPath = !is_null($parentFullPath) ? $parentFullPath . '/' . $category->getPath() : $category->getPath(); $category->setFullPath($fullPath); $url = '/catalog/' . $fullPath; $productsRel = $this->_modelMapper->fetchProductsRel($categoryId); if ($productsRel) { $productsMapper = new Catalog_Model_Mapper_Products(); /** @var Catalog_Model_Products $product */ foreach ($productsRel as $product) { $product->setFullPath($fullPath . '/' . $product->getPath()); $productsMapper->save($product); } } $upload = new Zend_File_Transfer(); if ($upload->isUploaded()) { $imageFile = $this->_uploadFiles($categoryId, $upload); $category->setUploadPath('/upload/categories/' . $categoryId . '/'); $category->setImage($imageFile['fileLoad']['name']); } $this->_modelMapper->save($category); } $this->clearCache('CatalogCategories'); $this->_redirector->gotoUrlAndExit($url); } }