public function parseResults(LoopResult $loopResult)
 {
     foreach ($loopResult->getResultDataCollection() as $rule) {
         $loopResultRow = new LoopResultRow($rule);
         $area = AreaQuery::create()->findOneById($rule->getAreaId());
         $loopResultRow->set("ID", $rule->getId())->set("AMOUNT", $rule->getAmount())->set("AREA_ID", $rule->getAreaId())->set("AREA_NAME", $area->getName());
         $loopResult->addRow($loopResultRow);
     }
     return $loopResult;
 }
 public function updateRule(FreeShippingUpdateEvent $event)
 {
     $areaId = $event->getArea();
     $freeShippingArea = FreeShippingQuery::create()->findOneByAreaId($areaId);
     if (null === $freeShippingArea || $freeShippingArea->getAmount() !== $event->getAmount()) {
         $id = $event->getRuleId();
         if (null !== ($freeShipping = FreeShippingQuery::create()->findPk($id))) {
             $freeShipping->setDispatcher($event->getDispatcher());
             $freeShipping->setAreaId($event->getArea())->setAmount($event->getAmount())->save();
             $event->setRule($freeShipping);
         }
     } else {
         $area = AreaQuery::create()->findOneById($areaId);
         throw new \Exception(sprintf("A free shipping rule already exists for the '%s' area", $area->getName()));
     }
 }