function GetProductProperty($product_id)
 {
     $products = new Catalog_Model_Mapper_Products();
     $productsParams = new Catalog_Model_Mapper_ProductParams();
     $select = $productsParams->getDbTable()->select()->order('order ASC');
     $entries = $products->findProductParams($product_id, $select);
     return $entries;
 }
 public function propertyDelAction()
 {
     //Zend_Debug::dump($this->_request->getParams());
     $response = '';
     if ($this->_request->getParam('id')) {
         $id = $this->_request->getParam('id');
         $this->_paramsMapper->delete($id);
         $response = 'deleted';
     }
     $this->_helper->json->sendJson($response);
 }
 /**
  * @param SimpleXMLElement $element
  * @param Catalog_Model_Products $product
  * @return SimpleXMLElement
  */
 public function addPropertiesProductXml(SimpleXMLElement $element, Catalog_Model_Products $product)
 {
     $selectParams = $this->_productsParamsMapper->getDbTable()->select()->order('order ASC');
     $productParams = $this->_productsModelMapper->findProductParams($product->getId(), $selectParams);
     if ($productParams && !empty($productParams)) {
         foreach ($productParams as $productParam) {
             /* @var $productParam Catalog_Model_ProductParams */
             $element->addChild('property', $productParam->getValue())->addAttribute('name', $productParam->getName());
         }
     }
     return $element;
 }
 /**
  * Свойства основного товара
  *
  * @return $this
  * @throws Zend_Exception
  */
 public function showProperty()
 {
     $products = new Catalog_Model_Mapper_Products();
     $product = $this->getProduct();
     $productsParams = new Catalog_Model_Mapper_ProductParams();
     $select = $productsParams->getDbTable()->select()->order('order ASC');
     $properties = $products->findProductParams($product->getId(), $select);
     $x = $this->getImageRBX() + 5;
     if (!empty($properties)) {
         $w = array(60, $this->getPageWidth() - $this->original_rMargin - $x - 60);
         foreach ($properties as $property) {
             $this->SetFont('', 'B', 10);
             $this->MultiCell($w[0], 0, $property->name, 0, 'L', false, 0, $x, '', true, 0, false, true, 0);
             $this->SetFont('', '', 10);
             $this->MultiCell($w[1], 0, $property->value, 0, 'L', false, 0, '', '', true, 0, false, true, 0);
             $this->Ln();
         }
     }
     $this->Ln(5);
     if ($this->y < $this->getImageRBY() + 5) {
         $this->SetX($x);
     }
     return $this;
 }
 /**
  * @param Catalog_Model_Products $product
  * @param bool $toWin
  * @return array
  */
 public function productProperty_Csv(Catalog_Model_Products $product, $toWin = false)
 {
     $productMapper = new Catalog_Model_Mapper_Products();
     $productsParamsMapper = new Catalog_Model_Mapper_ProductParams();
     $select = $productsParamsMapper->getDbTable()->select()->order('order ASC');
     $productParams = $productMapper->findProductParams($product->getId(), $select);
     $property = array();
     if (!empty($productParams)) {
         foreach ($productParams as $key => $productParam) {
             $property['name']['property_' . $key . '_name'] = !$toWin ? $productParam->getName() : $this->_toWindow($productParam->getName());
             $property['value']['property_' . $key . '_value'] = !$toWin ? $productParam->getValue() : $this->_toWindow($productParam->getValue());
         }
     }
     return $property;
 }
 /**
  * @param $id
  * @param Zend_Db_Table_Select|null $select
  * @return array|null
  * @throws Zend_Db_Table_Exception
  * @throws Zend_Db_Table_Row_Exception
  */
 public function findProductParams($id, Zend_Db_Table_Select $select = null, $isArray = false)
 {
     $result = $this->getDbTable()->find($id);
     if (0 == count($result)) {
         return null;
     }
     $product = $result->current();
     $resultSet = $product->findDependentRowset('Catalog_Model_DbTable_ProductParams', 'ProductsRel', $select);
     $entries = array();
     $modelMapper = new Catalog_Model_Mapper_ProductParams();
     foreach ($resultSet as $row) {
         $entry = new Catalog_Model_ProductParams();
         $entry = $modelMapper->_setDbData($row, $entry);
         $entries[] = !$isArray ? $entry : $entry->getOptions();
     }
     return $entries;
 }
 /**
  * @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())));
     }
 }