Esempio n. 1
0
 /**
  * @param array $data
  * @return Struct\Country
  */
 public function hydrateCountry(array $data)
 {
     $country = new Struct\Country();
     $translation = $this->getTranslation($data, '__country_translation', '__country_translation_fallback', $data['__country_id'], $this->translationCountryFields);
     $data = array_merge($data, $translation);
     $country->setId((int) $data['__country_id']);
     $country->setName($data['__country_countryname']);
     if (isset($data['__country_countryiso'])) {
         $country->setIso($data['__country_countryiso']);
     }
     if (isset($data['__country_iso3'])) {
         $country->setIso3($data['__country_iso3']);
     }
     if (isset($data['__country_notice'])) {
         $country->setDescription($data['__country_notice']);
     }
     if (isset($data['__country_countryen'])) {
         $country->setEn($data['__country_countryen']);
     }
     if (isset($data['__country_display_state_in_registration'])) {
         $country->setDisplayStateSelection((bool) $data['__country_display_state_in_registration']);
     }
     if (isset($data['__country_force_state_in_registration'])) {
         $country->setRequiresStateSelection((bool) $data['__country_force_state_in_registration']);
     }
     if (isset($data['__country_shippingfree'])) {
         $country->setShippingFree((bool) $data['__country_shippingfree']);
     }
     if (isset($data['__country_taxfree'])) {
         $country->setTaxFree((bool) $data['__country_taxfree']);
     }
     if (isset($data['__country_taxfree_ustid'])) {
         $country->setTaxFreeForVatId((bool) $data['__country_taxfree_ustid']);
     }
     if (isset($data['__country_taxfree_ustid_checked'])) {
         $country->setVatIdCheck((bool) $data['__country_taxfree_ustid_checked']);
     }
     if ($data['__countryAttribute_id'] !== null) {
         $attribute = $this->attributeHydrator->hydrate($this->extractFields('__countryAttribute_', $data));
         $country->addAttribute('core', $attribute);
     }
     return $country;
 }
Esempio n. 2
0
 /**
  * @param Struct\Customer\Group $customerGroup
  * @param Struct\Country\Area $area
  * @param Struct\Country $country
  * @param Struct\Country\State $state
  * @return \Doctrine\DBAL\Query\QueryBuilder
  */
 private function getAreaQuery(Struct\Customer\Group $customerGroup = null, Struct\Country\Area $area = null, Struct\Country $country = null, Struct\Country\State $state = null)
 {
     $query = $this->connection->createQueryBuilder();
     $query->select($this->fieldHelper->getTaxRuleFields());
     $query->from('s_core_tax_rules', 'taxRule');
     $areaId = $area ? $area->getId() : null;
     $countryId = $country ? $country->getId() : null;
     $stateId = $state ? $state->getId() : null;
     $query->andWhere('(taxRule.areaID = :area OR taxRule.areaID IS NULL)')->setParameter(':area', $areaId);
     $query->andWhere('(taxRule.countryID = :country OR taxRule.countryID IS NULL)')->setParameter(':country', $countryId);
     $query->andWhere('(taxRule.stateID = :state OR taxRule.stateID IS NULL)')->setParameter(':state', $stateId);
     $query->andWhere('(taxRule.customer_groupID = :customerGroup OR taxRule.customer_groupID IS NULL)')->setParameter(':customerGroup', $customerGroup->getId());
     $query->andWhere('taxRule.groupID = :taxId')->andWhere('taxRule.active = 1');
     $query->orderBy('taxRule.customer_groupID', 'DESC')->addOrderBy('taxRule.areaID', 'DESC')->addOrderBy('taxRule.countryID', 'DESC')->addOrderBy('taxRule.stateID', 'DESC');
     $query->setFirstResult(0)->setMaxResults(1);
     return $query;
 }