Пример #1
0
 /**
  * @param \Generated\Shared\Transfer\DiscountConfiguratorTransfer $discountConfiguratorTransfer
  *
  * @throws \Spryker\Zed\Discount\Business\Exception\PersistenceException
  *
  * @return bool
  */
 public function update(DiscountConfiguratorTransfer $discountConfiguratorTransfer)
 {
     $idDiscount = $discountConfiguratorTransfer->requireDiscountGeneral()->getDiscountGeneral()->requireIdDiscount()->getIdDiscount();
     $discountEntity = $this->discountQueryContainer->queryDiscount()->findOneByIdDiscount($idDiscount);
     if (!$discountEntity) {
         throw new PersistenceException(sprintf('Discount with id "%d" not found in database.', $idDiscount));
     }
     $this->hydrateDiscountEntity($discountConfiguratorTransfer, $discountEntity);
     if ($discountConfiguratorTransfer->getDiscountGeneral()->getDiscountType() === DiscountConstants::TYPE_VOUCHER) {
         $this->saveVoucherPool($discountEntity);
     }
     $affectedRows = $discountEntity->save();
     return $affectedRows > 0;
 }