Ejemplo n.º 1
0
 /**
  *
  * makeBean
  * @param array $resultset
  * @return \Application\Model\Bean\ProductPriceList
  */
 protected function makeBean($resultset)
 {
     return ProductPriceListFactory::createFromArray($resultset);
 }
Ejemplo n.º 2
0
 /**
  *
  * @return array
  */
 public function updateAction()
 {
     if ($this->getRequest()->isPost()) {
         $params = $this->getRequest()->getParams();
         $id = $this->getRequest()->getParam('id_product');
         $prices = $params['dc'];
         $baseProduct = ProductQuery::create()->findByPK($id);
         $status = $params['status'];
         $products = ProductQuery::create()->whereAdd(Product::ITEM_CODE, $baseProduct->getKeyMother(), ProductQuery::LIKE)->whereAdd(Product::STATUS, $status, ProductQuery::IN)->find();
         $this->getProductPriceListCatalog()->beginTransaction();
         while ($product = $products->read()) {
             if (ProductPriceListQuery::create()->whereAdd(ProductPriceList::ID_PRODUCT, $product->getItemCode())->find()->count()) {
                 $productPriceList = ProductPriceListQuery::create()->whereAdd(ProductPriceList::ID_PRODUCT, $product->getItemCode())->findOne();
             } else {
                 $productPriceList = new ProductPriceList();
             }
             try {
                 ProductPriceListFactory::populate($productPriceList, $params);
                 $productPriceList->setIdProduct($product->getItemCode());
                 if ($productPriceList->getIdProductPriceList()) {
                     $this->getProductPriceListCatalog()->update($productPriceList);
                     $this->updateProductPriceListInSap($product->getItemCode(), $prices[$product->getItemCode()]);
                     $this->newLogForUpdate($productPriceList);
                 } else {
                     $this->getProductPriceListCatalog()->create($productPriceList);
                     $this->newLogForCreate($productPriceList);
                 }
             } catch (Exception $e) {
                 $this->getProductPriceListCatalog()->rollBack();
                 $this->setFlash('error', $this->i18n->_($e->getMessage()));
                 $this->_redirect('product/list');
             }
         }
     }
     $this->getProductPriceListCatalog()->commit();
     $this->setFlash('ok', $this->i18n->_("Se actualizo correctamente el ProductPriceList"));
     $this->_redirect('product/list');
 }