/** * @param array $data * @return Struct\Customer\Group */ public function hydrate(array $data) { $customerGroup = new Struct\Customer\Group(); $customerGroup->setId((int) $data['__customerGroup_id']); $customerGroup->setName($data['__customerGroup_description']); $customerGroup->setDisplayGrossPrices((bool) $data['__customerGroup_tax']); $customerGroup->setKey($data['__customerGroup_groupkey']); $customerGroup->setMinimumOrderValue((double) $data['__customerGroup_minimumorder']); $customerGroup->setPercentageDiscount((double) $data['__customerGroup_discount']); $customerGroup->setSurcharge((double) $data['__customerGroup_minimumordersurcharge']); $customerGroup->setUseDiscount((bool) $data['__customerGroup_mode']); if (!empty($data['__customerGroupAttribute_id'])) { $attribute = $this->attributeHydrator->hydrate($this->extractFields('__customerGroupAttribute_', $data)); $customerGroup->addAttribute('core', $attribute); } return $customerGroup; }
/** * Creates a simple product which contains all required * data for an quick product creation. * * @param $number * @param Tax $tax * @param Group $customerGroup * @param float $priceOffset * @return array */ public function getSimpleProduct($number, $tax, Group $customerGroup, $priceOffset = 0.0) { if ($customerGroup instanceof Models\Customer\Group) { $struct = new Group(); $struct->setId($customerGroup->getId()); $struct->setKey($customerGroup->getKey()); $struct->setName($customerGroup->getName()); } $data = $this->getProductData(array('taxId' => $tax->getId())); $data['mainDetail'] = $this->getVariantData(array('number' => $number)); $data['mainDetail']['prices'] = $this->getGraduatedPrices($customerGroup->getKey(), $priceOffset); $data['mainDetail'] += $this->getUnitData(); return $data; }