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 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; }
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(); }
/** * @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()))); } }