コード例 #1
0
ファイル: Product.php プロジェクト: alex63530/thelia
 /**
  * Change a product
  *
  * @param \Thelia\Core\Event\Product\ProductUpdateEvent $event
  */
 public function update(ProductUpdateEvent $event)
 {
     if (null !== ($product = ProductQuery::create()->findPk($event->getProductId()))) {
         $product->setDispatcher($event->getDispatcher())->setRef($event->getRef())->setLocale($event->getLocale())->setTitle($event->getTitle())->setDescription($event->getDescription())->setChapo($event->getChapo())->setPostscriptum($event->getPostscriptum())->setVisible($event->getVisible() ? 1 : 0)->setVirtual($event->getVirtual() ? 1 : 0)->setBrandId($event->getBrandId() <= 0 ? null : $event->getBrandId())->save();
         // Update default category (ifd required)
         $product->updateDefaultCategory($event->getDefaultCategory());
         $event->setProduct($product);
     }
 }
コード例 #2
0
ファイル: Product.php プロジェクト: badelas/thelia
 /**
  * Change a product
  *
  * @param \Thelia\Core\Event\Product\ProductUpdateEvent $event
  */
 public function update(ProductUpdateEvent $event)
 {
     if (null !== ($product = ProductQuery::create()->findPk($event->getProductId()))) {
         $con = Propel::getWriteConnection(ProductTableMap::DATABASE_NAME);
         $con->beginTransaction();
         try {
             $product->setDispatcher($event->getDispatcher())->setRef($event->getRef())->setLocale($event->getLocale())->setTitle($event->getTitle())->setDescription($event->getDescription())->setChapo($event->getChapo())->setPostscriptum($event->getPostscriptum())->setVisible($event->getVisible() ? 1 : 0)->setVirtual($event->getVirtual() ? 1 : 0)->setBrandId($event->getBrandId() <= 0 ? null : $event->getBrandId())->save($con);
             // Update default category (ifd required)
             $product->updateDefaultCategory($event->getDefaultCategory());
             $event->setProduct($product);
             $con->commit();
         } catch (PropelException $e) {
             $con->rollBack();
             throw $e;
         }
     }
 }
コード例 #3
0
ファイル: Product.php プロジェクト: margery/thelia
 /**
  * Change a product
  *
  * @param \Thelia\Core\Event\Product\ProductUpdateEvent $event
  */
 public function update(ProductUpdateEvent $event)
 {
     if (null !== ($product = ProductQuery::create()->findPk($event->getProductId()))) {
         $con = Propel::getWriteConnection(ProductTableMap::DATABASE_NAME);
         $con->beginTransaction();
         try {
             $prevRef = $product->getRef();
             $product->setDispatcher($event->getDispatcher())->setRef($event->getRef())->setLocale($event->getLocale())->setTitle($event->getTitle())->setDescription($event->getDescription())->setChapo($event->getChapo())->setPostscriptum($event->getPostscriptum())->setVisible($event->getVisible() ? 1 : 0)->setVirtual($event->getVirtual() ? 1 : 0)->setBrandId($event->getBrandId() <= 0 ? null : $event->getBrandId())->save($con);
             // Update default PSE (if product has no attributes and the product's ref change)
             $defaultPseRefChange = $prevRef !== $product->getRef() && 0 === $product->getDefaultSaleElements()->countAttributeCombinations();
             if ($defaultPseRefChange) {
                 $defaultPse = $product->getDefaultSaleElements();
                 $defaultPse->setRef($product->getRef())->save();
             }
             // Update default category (if required)
             $product->updateDefaultCategory($event->getDefaultCategory());
             $event->setProduct($product);
             $con->commit();
         } catch (PropelException $e) {
             $con->rollBack();
             throw $e;
         }
     }
 }