public function productModificationTableTitle(Catalog_Model_Products $product, $toWin = false)
 {
     $select = $this->_subproductsParamsMapper->getDbTable()->select()->order('order ASC');
     $subproductProperty = $this->_productsModelMapper->findSubproductParams($product->getId(), $select);
     $modificationTableTitle = array();
     if (!empty($subproductProperty)) {
         $modificationTableTitle[] = !$toWin ? 'Название' : $this->_toWindow('Название');
         foreach ($subproductProperty as $name) {
             $modificationTableTitle[] = !$toWin ? $name->getName() : $this->_toWindow($name->getName());
         }
     }
     return $modificationTableTitle;
 }
 /**
  * @param SimpleXMLElement $element
  * @param Catalog_Model_Products $product
  */
 public function addModificationTableXml(SimpleXMLElement $element, Catalog_Model_Products $product)
 {
     $selectModification = $this->_subproductsModelMapper->getDbTable()->select()->order('order ASC');
     $cache = Zend_Cache::factory('Core', 'File', array('lifetime' => 3600 * 24 * 2, 'automatic_serialization' => true), array('cache_dir' => '../cache/modifications/'));
     if (!($modifications = $cache->load('modifications' . $product->getId()))) {
         $modifications = $this->_productsModelMapper->findSubproductsRel($product->getId(), $selectModification);
         $cache->save($modifications, 'modifications' . $product->getId(), array('modificationsTable'));
     }
     if ($modifications && !empty($modifications)) {
         $selectSubproductParams = $this->_subproductsParamsMapper->getDbTable()->select()->order('order ASC');
         $subproductProperty = $this->_productsModelMapper->findSubproductParams($product->getId(), $selectSubproductParams);
         foreach ($modifications as $modification) {
             /* @var $modification Catalog_Model_Subproducts */
             $row = $element->addChild('tr');
             $row->addAttribute('id', $modification->getId());
             $row->addChild('td', $modification->getSku())->addAttribute('title', 'Наименование');
             foreach ($subproductProperty as $property) {
                 /* @var $property Catalog_Model_SubproductParams */
                 $row->addChild('td', $this->_getModificationParamValue($modification->getId(), $property->getId()))->addAttribute('title', $property->getName());
             }
         }
     }
 }
 /**
  * @param Zend_Db_Table_Rowset $row
  * @param Catalog_Model_Products $entry
  * @return Catalog_Model_Products
  */
 public function _setDbData($row, Catalog_Model_Products $entry)
 {
     $info = $this->getDbTable()->info();
     $properties = $info['cols'];
     foreach ($properties as $property) {
         $entry->__set($this->_normaliseName($property), $row->{$property});
     }
     return $entry;
 }
 /**
  * @param Catalog_Model_Products $product
  * @return array
  */
 public function getElementsModifications(Catalog_Model_Products $product)
 {
     $result = array();
     $modifications = $this->_getProductModifications($product->getId());
     if ($modifications) {
         foreach ($modifications as $modification) {
             $result[] = array('id' => str_replace(' ', '', $modification->getSku()), 'nm' => $modification->getSku());
         }
     }
     return $result;
 }
 public function addAction()
 {
     if ($this->_request->isPost()) {
         $url = $this->_request->getParam('currentUrl');
         if ($this->_request->getParam('dataFormProducts')) {
             $dataProducts = $this->_request->getParam('dataFormProducts');
             //основные - sku, name, description, note, sorting, path
             $product = new Catalog_Model_Products($dataProducts);
             //modDate, order
             $product->setMetaTitle($dataProducts['name'])->setMetaDescription($dataProducts['description'])->setMetaKeywords($dataProducts['name'])->setOrder($dataProducts['sorting'])->setActive(1)->setDeleted(0)->setAddDate(date("Y-m-d H:i:s"))->setModDate(date("Y-m-d H:i:s"));
             $this->_modelMapper->save($product);
             $productId = $this->_modelMapper->getDbTable()->getAdapter()->lastInsertId();
             $categoriesMapperXref = new Catalog_Model_Mapper_CategoriesXref();
             $categoriesMapperXref->save(new Catalog_Model_CategoriesXref(array('productId' => $productId, 'categoryId' => $this->_request->getParam('categoryId'))));
             $product = $this->_modelMapper->find($productId, $this->_model);
             $upload = new Zend_File_Transfer();
             $uploadPath = '/upload/products/' . $product->getId() . '/';
             //image
             if ($upload->isUploaded('fileLoadImage')) {
                 $imageFile = $this->_uploadFiles($productId, $upload, 'fileLoadImage');
                 $product->setUploadPath($uploadPath)->setImage($imageFile['fileLoadImage']['name']);
             }
             //draft
             if ($upload->isUploaded('fileLoadDraft')) {
                 $imageFile = $this->_uploadFiles($productId, $upload, 'fileLoadDraft');
                 $product->setUploadPathDraft($uploadPath)->setDraft($imageFile['fileLoadDraft']['name']);
             }
             $this->_modelMapper->save($product);
             $url = '/catalog/' . $product->getFullPath();
         }
         $this->clearCache('CatalogProductsList');
         $this->_redirector->gotoUrlAndExit($url);
     }
     //Zend_Debug::dump($this->_request->getParams());
 }