Esempio n. 1
0
 /**
  * Save/delete coupon
  *
  * @return $this
  */
 public function afterSave()
 {
     $couponCode = trim($this->getCouponCode());
     if (strlen($couponCode) && $this->getCouponType() == self::COUPON_TYPE_SPECIFIC && !$this->getUseAutoGeneration()) {
         $this->getPrimaryCoupon()->setCode($couponCode)->setUsageLimit($this->getUsesPerCoupon() ? $this->getUsesPerCoupon() : null)->setUsagePerCustomer($this->getUsesPerCustomer() ? $this->getUsesPerCustomer() : null)->setExpirationDate($this->getToDate())->save();
     } else {
         $this->getPrimaryCoupon()->delete();
     }
     parent::afterSave();
     return $this;
 }
Esempio n. 2
0
 /**
  * {@inheritdoc}
  *
  * @return $this
  */
 public function afterSave()
 {
     if ($this->isObjectNew()) {
         $this->getMatchingProductIds();
         if (!empty($this->_productIds) && is_array($this->_productIds)) {
             $this->_ruleProductProcessor->reindexList($this->_productIds);
         }
     } else {
         $this->_ruleProductProcessor->getIndexer()->invalidate();
     }
     return parent::afterSave();
 }