コード例 #1
0
 /**
  * @param Struct\Customer\Group $customerGroup
  * @param Struct\ShopContextInterface $context
  * @return array|Struct\Product\PriceGroup[]
  */
 public function getPriceGroups(Struct\Customer\Group $customerGroup, Struct\ShopContextInterface $context)
 {
     $query = $this->connection->createQueryBuilder();
     $query->addSelect('priceGroupDiscount.groupID')->addSelect($this->fieldHelper->getPriceGroupDiscountFields())->addSelect($this->fieldHelper->getPriceGroupFields());
     $query->from('s_core_pricegroups_discounts', 'priceGroupDiscount')->innerJoin('priceGroupDiscount', 's_core_pricegroups', 'priceGroup', 'priceGroup.id = priceGroupDiscount.groupID');
     $query->andWhere('priceGroupDiscount.customergroupID = :customerGroup');
     $query->groupBy('priceGroupDiscount.id');
     $query->orderBy('priceGroupDiscount.groupID')->addOrderBy('priceGroupDiscount.discountstart');
     $query->setParameter(':customerGroup', $customerGroup->getId());
     /**@var $statement \Doctrine\DBAL\Driver\ResultStatement */
     $statement = $query->execute();
     $data = $statement->fetchAll(\PDO::FETCH_GROUP);
     $priceGroups = [];
     foreach ($data as $row) {
         $priceGroup = $this->priceHydrator->hydratePriceGroup($row);
         foreach ($priceGroup->getDiscounts() as $discount) {
             $discount->setCustomerGroup($customerGroup);
         }
         $priceGroups[$priceGroup->getId()] = $priceGroup;
     }
     return $priceGroups;
 }
コード例 #2
0
 /**
  * @param Struct\Customer\Group $customerGroup
  * @return NotFilter
  */
 protected function getCustomerGroupFilter(Struct\Customer\Group $customerGroup)
 {
     return new NotFilter(new TermsFilter('blockedCustomerGroupIds', [$customerGroup->getId()]));
 }
コード例 #3
0
ファイル: Helper.php プロジェクト: GerDner/luck-docker
 /**
  * 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;
 }
コード例 #4
0
ファイル: TaxGateway.php プロジェクト: GerDner/luck-docker
 /**
  * @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;
 }