/**
  * @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;
 }
Esempio n. 2
0
 /**
  * @param Models\Customer\Group $group
  * @return Struct\Customer\Group
  */
 public function convertCustomerGroup(Models\Customer\Group $group)
 {
     $customerGroup = new Struct\Customer\Group();
     $customerGroup->setKey($group->getKey());
     $customerGroup->setUseDiscount($group->getMode());
     $customerGroup->setId($group->getId());
     $customerGroup->setPercentageDiscount($group->getDiscount());
     $customerGroup->setDisplayGrossPrices($group->getTax());
     $customerGroup->setMinimumOrderValue($group->getMinimumOrder());
     $customerGroup->setSurcharge($group->getMinimumOrderSurcharge());
     return $customerGroup;
 }
Esempio n. 3
0
 /**
  * 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;
 }