public function createRule(FreeShippingEvents $event) { $rule = new FreeShipping(); $freeShippingArea = FreeShippingQuery::create()->findOneByAreaId($event->getArea()); if (null === $freeShippingArea) { $rule->setAmount($event->getAmount())->setAreaId($event->getArea())->save(); } else { $area = AreaQuery::create()->findOneById($event->getArea()); throw new \Exception(sprintf("A free shipping rule already exists for the '%s' area", $area->getName())); } }
/** * Exclude object from result * * @param ChildFreeShipping $freeShipping Object to remove from the list of results * * @return ChildFreeShippingQuery The current query, for fluid interface */ public function prune($freeShipping = null) { if ($freeShipping) { $this->addUsingAlias(FreeShippingTableMap::ID, $freeShipping->getId(), Criteria::NOT_EQUAL); } return $this; }