Exemplo n.º 1
0
 /**
  * @param Models\Price\Group $entity
  * @return Struct\Product\PriceGroup
  */
 public function convertPriceGroup(Models\Price\Group $entity)
 {
     $struct = new Struct\Product\PriceGroup();
     $struct->setId($entity->getId());
     $struct->setName($entity->getName());
     $discounts = array();
     foreach ($entity->getDiscounts() as $discountEntity) {
         $discount = new Struct\Product\PriceDiscount();
         $discount->setId($discountEntity->getId());
         $discount->setPercent($discountEntity->getDiscount());
         $discount->setQuantity($discountEntity->getStart());
         $discounts[] = $discount;
     }
     $struct->setDiscounts($discounts);
     return $struct;
 }
Exemplo n.º 2
0
 /**
  * @param $data
  * @return Struct\Product\PriceGroup
  */
 public function hydratePriceGroup($data)
 {
     $group = new Struct\Product\PriceGroup();
     $first = $data[0];
     $group->setId((int) $first['__priceGroup_id']);
     $group->setName($first['__priceGroup_description']);
     $discounts = [];
     foreach ($data as $row) {
         $discounts[] = $this->hydratePriceDiscount($row);
     }
     $group->setDiscounts($discounts);
     return $group;
 }