/** * @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; }
/** * @param array $data * @return Struct\Product\PriceDiscount */ public function hydratePriceDiscount(array $data) { $discount = new Struct\Product\PriceDiscount(); $discount->setId((int) $data['__priceGroupDiscount_id']); $discount->setPercent((double) $data['__priceGroupDiscount_discount']); $discount->setQuantity((int) $data['__priceGroupDiscount_discountstart']); return $discount; }