public function modificationsAction()
 {
     $id = $this->_request->getParam('id');
     $select = $this->_subproductsModelMapper->getDbTable()->select()->where('deleted != ?', 1)->order('order ASC');
     $jsonData = array('parentId' => $id, 'columns' => array(), 'rows' => array());
     $modifications = $this->_modelMapper->findSubproductsRel($id, $select, true);
     if (!empty($modifications)) {
         $selectSubproductParams = $this->_subproductsParamsMapper->getDbTable()->select()->order('order ASC');
         $subproductProperty = $this->_modelMapper->findSubproductParams($id, $selectSubproductParams, true);
         $jsonData['columns'] = $subproductProperty;
         $modificationsTableValues = array();
         foreach ($modifications as $modification) {
             $modificationPropertyValues = $this->_subproductsModelMapper->findSubProductParamValue($modification['id']);
             $values['item'] = $modification;
             $values['values'] = array();
             foreach ($modificationPropertyValues as $modificationPropertyValue) {
                 $values['values'][] = $modificationPropertyValue->getOptions();
             }
             $modificationsTableValues[] = $values;
         }
         $jsonData['rows'] = $modificationsTableValues;
         //Zend_Debug::dump($jsonData);
     }
     $this->_helper->json->sendJson($jsonData);
 }
 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;
 }
 /**
  * @param int $category_id
  * @param int $active
  * @return array
  */
 function GetProductsCategory($category_id, $active = 0)
 {
     $categories = new Catalog_Model_Mapper_Categories();
     $productsMapper = new Catalog_Model_Mapper_Products();
     $select = $productsMapper->getDbTable()->select();
     $select->where('active != ?', $active)->order('sorting ASC');
     $entries = $categories->fetchProductsRel($category_id, $select);
     return $entries;
 }
 public function autocompleteAction()
 {
     $this->_helper->layout()->disableLayout();
     $query = $this->getRequest()->getParam('query');
     $productsMapper = new Catalog_Model_Mapper_Products();
     if ($this->_request->getParam('query')) {
         $query = str_replace(array('.', ',', ' ', '-', '_', '/', '\\', '*', '+', '&', '^', '%', '#', '@', '!', '(', ')', '~', '<', '>', ':', ';', '"', "'", "|"), '', $query);
         //$nameQuery = $this->_request->getParam('query');
         //$sQuery = "(`s_name` LIKE '%$query%' OR `name` LIKE '%$nameQuery%')";
         $sQuery = "MATCH(s_name, sku, name, meta_keywords) AGAINST ('+{$query}*' IN BOOLEAN MODE)";
         $select = $productsMapper->getDbTable()->select();
         $select->where('active != ?', 0)->where('deleted != ?', 1)->where($sQuery)->limit(15)->order("CHAR_LENGTH(sku) ASC");
         $products = $productsMapper->fetchAll($select);
         if (!empty($products)) {
             $this->view->assign('products', $products);
         }
     }
 }
 public function indexAction()
 {
     $productsMapper = new Catalog_Model_Mapper_Products();
     $products = $productsMapper->fetchAll();
     $countDraft = 0;
     /** @var Catalog_Model_Products $product */
     foreach ($products as $product) {
         if (!is_null($product->getAImages())) {
             $draftImages = unserialize($product->getAImages());
             if (!empty($draftImages)) {
                 $product->setDraft($draftImages[0]);
                 $productsMapper->save($product);
             }
             $countDraft++;
         }
     }
     Zend_Debug::dump($countDraft, 'Сгенерировано чертежей: ', true);
 }
 public function indexAction()
 {
     $productsMapper = new Catalog_Model_Mapper_Products();
     $jsonData = array();
     if ($this->_request->getParam('query')) {
         $query = $this->_request->getParam('query');
         $query = str_replace(array('.', ',', ' ', '-', '_', '/', '\\', '*', '+', '&', '^', '%', '#', '@', '!', '(', ')', '~', '<', '>', ':', ';', '"', "'", "|"), '', $query);
         //$nameQuery = $this->_request->getParam('query');
         //$sQuery = "(`s_name` LIKE '%$query%' OR `name` LIKE '%$nameQuery%')";
         $sQuery = "MATCH(s_name, sku, name) AGAINST ('+{$query}*' IN BOOLEAN MODE)";
         $select = $productsMapper->getDbTable()->select();
         if (!Zend_Auth::getInstance()->hasIdentity()) {
             $select->where('active != ?', 0)->where('deleted != ?', 1);
         }
         $select->where($sQuery)->limit(15)->order("CHAR_LENGTH(sku) ASC");
         $products = $productsMapper->fetchAll($select, true);
         $products && ($jsonData = $products);
     }
     $this->_helper->json->sendJson($jsonData);
 }
 /**
  * @param $id_product
  * @return Catalog_Model_Subproducts[]|null
  */
 private function _getProductModifications($id_product)
 {
     $cache = Zend_Registry::get('cache');
     $cacheName = 'productModifications_' . $id_product;
     if (!($modifications = $cache->load($cacheName))) {
         ini_set('max_execution_time', 900);
         $modifications = $this->_modelProductsMapper->findSubproductsRel($id_product);
         $cache->save($modifications, $cacheName, array('api', 'Catalog', 'productModifications'));
     }
     return $modifications;
 }
 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;
 }
Exemplo n.º 9
0
 public function redirectCatalogItem($item)
 {
     $category_id = $item['category_id'];
     $product_id = $item['product_id'];
     $fullPath = '';
     if (!is_null($category_id)) {
         $categoryMapper = new Catalog_Model_Mapper_Categories();
         $category = $categoryMapper->find($category_id, new Catalog_Model_Categories());
         if (!is_null($category)) {
             $fullPath = $category->getFullPath() . '/';
         }
     }
     if (!is_null($product_id)) {
         $productMapper = new Catalog_Model_Mapper_Products();
         $product = $productMapper->find($product_id, new Catalog_Model_Products());
         if (!is_null($product)) {
             $fullPath = $product->getFullPath() . '/';
         }
     }
     $url = '/catalog/' . $fullPath;
     Zend_Controller_Front::getInstance()->getResponse()->setRedirect($url, 301);
     return;
 }
 /**
  * @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());
             }
         }
     }
 }
Exemplo n.º 11
0
 /**
  * @param $id
  * @param null|Zend_Db_Table_Select $select
  * @return array|null
  * @throws Zend_Db_Table_Exception
  * @throws Zend_Db_Table_Row_Exception
  */
 public function fetchProductsRel($id, Zend_Db_Table_Select $select = null)
 {
     $result = $this->getDbTable()->find($id);
     if (0 == count($result)) {
         return null;
     }
     $category = $result->current();
     $resultSet = $category->findManyToManyRowset("Catalog_Model_DbTable_Products", "Catalog_Model_DbTable_CategoriesXref", null, null, $select);
     $entries = array();
     $products = new Catalog_Model_Mapper_Products();
     foreach ($resultSet as $row) {
         $entry = new Catalog_Model_Products();
         $entry = $products->_setDbData($row, $entry);
         $entries[] = $entry;
     }
     return $entries;
 }
 public function generateProductsFullPathAction()
 {
     $products = new Catalog_Model_Mapper_Products();
     $freePathProducts = $products->fetchFreeRowColumn('full_path');
     foreach ($freePathProducts as $product) {
         $product->fullPath = $products->generateFullPath($product->id);
         $mapper = new Catalog_Model_Mapper_Products();
         $mapper->save($product);
     }
     return $this->view->entries = $products->fetchFreeRowColumn('full_path');
 }
 public function passportAction()
 {
     //Zend_Debug::dump($this->_request->getParams());
     $product = $this->_modelMapper->find($this->_request->getParam('id'), $this->_model);
     if (!$product) {
         throw new Zend_Exception("Такого товара нет", 404);
     }
     $modificationsId = $this->_request->getParam('modifications');
     $modifications = array();
     if ($modificationsId && !empty($modificationsId)) {
         $select = $this->_subproductsModelMapper->getDbTable()->select();
         $select->where('id IN (?)', $modificationsId)->order('order ASC');
         $modifications = $this->_subproductsModelMapper->fetchAll($select);
     }
     $propertiesProduct = $this->_modelMapper->findProductParams($this->_request->getParam('id'));
     $select = $this->_subproductsParamsMapper->getDbTable()->select()->order('order ASC');
     $modificationsProperty = $this->_modelMapper->findSubproductParams($product->getId(), $select);
     $modificationsTableHead = '';
     $modificationsTableBody = '';
     if (!empty($modificationsProperty)) {
         $modificationsTableHead .= '<tr>';
         $modificationsTableHead .= '<th align="center" width="20%" style="font-weight: bolder">Название</th>';
         /**@var $value Catalog_Model_SubproductParams*/
         foreach ($modificationsProperty as $value) {
             $modificationsTableHead .= '<th align="center" style="font-weight: bolder">' . $value->getName() . '</th>';
         }
         $modificationsTableHead .= '</tr>';
         foreach ($modifications as $modification) {
             $modificationsTableBody .= '<tr>';
             $modificationsTableBody .= '<td width="20%" nowrap="nowrap">' . $modification->getSku() . '</td>';
             $modificationPropertyValues = $this->_subproductsModelMapper->findSubProductParamValue($modification->getId());
             /**@var $value Catalog_Model_SubproductParamsValues*/
             foreach ($modificationPropertyValues as $value) {
                 $modificationsTableBody .= '<td>' . $value->getValue() . '</td>';
             }
             $modificationsTableBody .= '</tr>';
         }
     }
     //Zend_Debug::dump($modificationsProperty);
     $pdf = new Admin_Model_PassportPdf();
     // set document information
     $pdf->SetAuthor('Альфа Гидро');
     $pdf->SetTitle('Паспорт');
     $pdf->SetSubject('Паспорт');
     $pdf->SetKeywords('Паспорт, PDF');
     $pdf->SetFont('', '', 12, '', true);
     // Set Product
     $pdf->setProduct($product);
     // Set Modifications
     $pdf->setAModificationsProduct($modifications);
     // Set PropertiesProduct
     $pdf->setPropertiesProduct($propertiesProduct);
     // Set Modification Table
     $pdf->setModificationTableHead($modificationsTableHead);
     $pdf->setModificationTableBody($modificationsTableBody);
     $pdf->AddPage();
     $pdf->showName()->showModificationsList()->showImages()->showProperty()->showModificatonTable()->showGarant('ГАРАНТИЙНЫЕ ОБЯЗАТЕЛЬСТВА', 'Компания гарантирует работоспособность указанных изделий в течение 1 (года) с момента изготовления. При обнаружении скрытого дефекта в период гарантийного срока фирма обязуется безвозмездно заменить изделие. Организация не несет ответственности за убытки, причиненные неисправностью установленного изделия. Гарантия не распространяется на изделия неправильно установленные или поврежденные механическими и химическими воздействиями, а так же, эксплуатируемыми в условиях не соответствующих указанным в настоящем паспорте.');
     $pdf->Output();
     $this->getResponse()->setHeader('Content-Type', 'application/pdf');
     $this->_helper->layout()->disableLayout();
 }
 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);
     }
 }
 function getCategoryProduct($id)
 {
     $productsMapper = new Catalog_Model_Mapper_Products();
     $category = $productsMapper->findCategoryRel($id, new Catalog_Model_Categories());
     return $category;
 }
Exemplo n.º 16
0
 /**
  * Свойства основного товара
  *
  * @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;
 }
 public function printAction()
 {
     $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);
     }
     $subproducts = new Catalog_Model_Mapper_Subproducts();
     $select = $subproducts->getDbTable()->select()->where('deleted != ?', 1)->order('order ASC');
     $modifications = $products->findSubproductsRel($product->getId(), $select);
     $tableModifications = array();
     $headTable = array();
     if (!empty($modifications)) {
         $subproductParams = new Catalog_Model_Mapper_SubproductParams();
         $select = $subproductParams->getDbTable()->select()->order('order ASC');
         $subproductProperty = $products->findSubproductParams($product->getId(), $select);
         $headTable[] = 'Название';
         foreach ($subproductProperty as $property) {
             $headTable[] = $property->name;
         }
         $tableModifications = $this->modificationsTableValues($modifications);
         array_unshift($tableModifications, $headTable);
     }
     //print_r(count(array_shift($tableModifications))-1);
     $pdf = new Catalog_Model_PrintPdf();
     // set document information
     $pdf->SetAuthor('Альфа Гидро');
     $pdf->SetTitle($this->transformSku($product->getSku()) . '. ' . $product->getName());
     $pdf->SetSubject($this->transformSku($product->getSku()) . '. ' . $product->getName());
     $pdf->SetKeywords($this->transformSku($product->getSku()) . ', ' . $product->getName());
     $pdf->SetFont('', '', 12, '', true);
     $pdf->setProduct($product);
     // Add a page
     $pdf->AddPage();
     $pdf->showImages()->showProperty()->showDescription()->showModificatonTable($tableModifications);
     $pdf->Output();
     $this->getResponse()->setHeader('Content-Type', 'application/pdf');
     $this->_helper->layout()->disableLayout();
 }