예제 #1
0
 /**
  * @inheritdoc
  */
 public function getRules(Struct\Customer\Group $customerGroup, Struct\Country\Area $area = null, Struct\Country $country = null, Struct\Country\State $state = null)
 {
     $query = $this->connection->createQueryBuilder();
     $query->select($this->fieldHelper->getTaxFields())->from('s_core_tax', 'tax');
     /**@var $statement \Doctrine\DBAL\Driver\ResultStatement */
     $statement = $query->execute();
     $data = $statement->fetchAll(\PDO::FETCH_ASSOC);
     $rules = [];
     $query = $this->getAreaQuery($customerGroup, $area, $country, $state);
     foreach ($data as $tax) {
         $query->setParameter(':taxId', $tax['__tax_id']);
         /**@var $statement \Doctrine\DBAL\Driver\ResultStatement */
         $statement = $query->execute();
         $area = $statement->fetch(\PDO::FETCH_ASSOC);
         if (!empty($area['__taxRule_tax'])) {
             $area['__taxRule_name'] = $tax['__tax_description'];
             $rule = $this->taxHydrator->hydrateRule($area);
         } else {
             $rule = $this->taxHydrator->hydrate($tax);
         }
         $key = 'tax_' . $tax['__tax_id'];
         $rules[$key] = $rule;
     }
     return $rules;
 }
예제 #2
0
 /**
  * @param Struct\ListProduct $product
  * @param array $data
  * @return Struct\ListProduct
  */
 private function assignData(Struct\ListProduct $product, array $data)
 {
     $translation = $this->getProductTranslation($data);
     $data = array_merge($data, $translation);
     $this->assignProductData($product, $data);
     $product->setTax($this->taxHydrator->hydrate($data));
     $this->assignPriceGroupData($product, $data);
     if ($data['__product_supplierID']) {
         $product->setManufacturer($this->manufacturerHydrator->hydrate($data));
     }
     if ($data['__esd_id']) {
         $product->setEsd($this->esdHydrator->hydrate($data));
     }
     $product->setUnit($this->unitHydrator->hydrate($data));
     if (!empty($data['__productAttribute_id'])) {
         $this->assignAttributeData($product, $data);
     }
     return $product;
 }