public function testAliasesCanBeRetrieved() { $mapping = ['sSearch' => 'q', 'sPage' => 'p']; $mapper = new QueryAliasMapper($mapping); $this->assertEquals('q', $mapper->getShortAlias('sSearch')); $this->assertEquals('p', $mapper->getShortAlias('sPage')); $this->assertEquals(null, $mapper->getShortAlias('somefoo')); }
/** * @param PriceHelper $priceHelper * @param QueryBuilderFactory $queryBuilderFactory * @param \Shopware_Components_Snippet_Manager $snippetManager * @param QueryAliasMapper $queryAliasMapper */ public function __construct(PriceHelper $priceHelper, QueryBuilderFactory $queryBuilderFactory, \Shopware_Components_Snippet_Manager $snippetManager, QueryAliasMapper $queryAliasMapper) { $this->priceHelper = $priceHelper; $this->queryBuilderFactory = $queryBuilderFactory; $this->snippetNamespace = $snippetManager->getNamespace('frontend/listing/facet_labels'); if (!($this->minFieldName = $queryAliasMapper->getShortAlias('priceMin'))) { $this->minFieldName = 'priceMin'; } if (!($this->maxFieldName = $queryAliasMapper->getShortAlias('priceMax'))) { $this->maxFieldName = 'priceMax'; } }
/** * @param QueryBuilderFactory $queryBuilderFactory * @param \Shopware_Components_Snippet_Manager $snippetManager * @param QueryAliasMapper $queryAliasMapper */ public function __construct(QueryBuilderFactory $queryBuilderFactory, \Shopware_Components_Snippet_Manager $snippetManager, QueryAliasMapper $queryAliasMapper) { $this->queryBuilderFactory = $queryBuilderFactory; $this->snippetNamespace = $snippetManager->getNamespace('frontend/listing/facet_labels'); if (!($this->fieldName = $queryAliasMapper->getShortAlias('shippingFree'))) { $this->fieldName = 'shippingFree'; } }
/** * @param Criteria $criteria * @param $items * @return ValueListFacetResult */ private function createFacet(Criteria $criteria, $items) { if (!($fieldName = $this->queryAliasMapper->getShortAlias('sSupplier'))) { $fieldName = 'sSupplier'; } $label = $this->snippetManager->getNamespace('frontend/listing/facet_labels')->get('manufacturer', 'Manufacturer'); return new ValueListFacetResult('manufacturer', $criteria->hasCondition('manufacturer'), $label, $items, $fieldName); }
/** * @param PropertyGatewayInterface $propertyGateway * @param QueryBuilderFactory $queryBuilderFactory * @param QueryAliasMapper $queryAliasMapper */ public function __construct(PropertyGatewayInterface $propertyGateway, QueryBuilderFactory $queryBuilderFactory, QueryAliasMapper $queryAliasMapper) { $this->propertyGateway = $propertyGateway; $this->queryBuilderFactory = $queryBuilderFactory; if (!($this->fieldName = $queryAliasMapper->getShortAlias('sFilterProperties'))) { $this->fieldName = 'sFilterProperties'; } }
/** * @param Criteria $criteria * @return BooleanFacetResult */ private function createFacet(Criteria $criteria) { $label = $this->snippetManager->getNamespace('frontend/listing/facet_labels')->get('immediate_delivery', 'Immediate delivery'); if (!($fieldName = $this->queryAliasMapper->getShortAlias('immediateDelivery'))) { $fieldName = 'immediateDelivery'; } $criteriaPart = new BooleanFacetResult('immediate_delivery', $fieldName, $criteria->hasCondition('immediate_delivery'), $label); return $criteriaPart; }
/** * @param ManufacturerServiceInterface $manufacturerService * @param QueryBuilderFactory $queryBuilderFactory * @param \Shopware_Components_Snippet_Manager $snippetManager * @param QueryAliasMapper $queryAliasMapper */ public function __construct(ManufacturerServiceInterface $manufacturerService, QueryBuilderFactory $queryBuilderFactory, \Shopware_Components_Snippet_Manager $snippetManager, QueryAliasMapper $queryAliasMapper) { $this->manufacturerService = $manufacturerService; $this->queryBuilderFactory = $queryBuilderFactory; $this->snippetNamespace = $snippetManager->getNamespace('frontend/listing/facet_labels'); if (!($this->fieldName = $queryAliasMapper->getShortAlias('sSupplier'))) { $this->fieldName = 'sSupplier'; } }
/** * @param CategoryServiceInterface $categoryService * @param QueryBuilderFactory $queryBuilderFactory * @param \Shopware_Components_Snippet_Manager $snippetManager * @param QueryAliasMapper $queryAliasMapper * @param Connection $connection */ public function __construct(CategoryServiceInterface $categoryService, QueryBuilderFactory $queryBuilderFactory, \Shopware_Components_Snippet_Manager $snippetManager, QueryAliasMapper $queryAliasMapper, Connection $connection) { $this->categoryService = $categoryService; $this->queryBuilderFactory = $queryBuilderFactory; $this->snippetNamespace = $snippetManager->getNamespace('frontend/listing/facet_labels'); $this->connection = $connection; if (!($this->fieldName = $queryAliasMapper->getShortAlias('sCategory'))) { $this->fieldName = 'sCategory'; } }
/** * @param Category[] $categories * @param int[] $active * @return TreeFacetResult */ private function createTreeFacet($categories, $active) { $items = $this->getCategoriesOfParent($categories, null); $values = []; foreach ($items as $item) { $values[] = $this->createTreeItem($categories, $item, $active); } $label = $this->snippetManager->getNamespace('frontend/listing/facet_labels')->get('category', 'Categories'); if (!($fieldName = $this->queryAliasMapper->getShortAlias('sCategory'))) { $fieldName = 'sCategory'; } return new TreeFacetResult('category', $fieldName, empty($active), $label, $values, [], null); }
/** * @param Criteria $criteria * @return RadioFacetResult */ private function createFacet(Criteria $criteria) { $activeAverage = null; if ($criteria->hasCondition('vote_average')) { /**@var $condition VoteAverageCondition*/ $condition = $criteria->getCondition('vote_average'); $activeAverage = $condition->getAverage(); } $values = [new ValueListItem(1, '', $activeAverage == 1), new ValueListItem(2, '', $activeAverage == 2), new ValueListItem(3, '', $activeAverage == 3), new ValueListItem(4, '', $activeAverage == 4), new ValueListItem(5, '', $activeAverage == 5)]; $label = $this->snippetManager->getNamespace('frontend/listing/facet_labels')->get('vote_average', 'Ranking'); if (!($fieldName = $this->queryAliasMapper->getShortAlias('rating'))) { $fieldName = 'rating'; } return new RadioFacetResult('vote_average', $criteria->hasCondition('vote_average'), $label, $values, $fieldName, [], 'frontend/listing/filter/facet-rating.tpl'); }
/** * @param Criteria $criteria * @param float $min * @param float $max * @return RangeFacetResult */ private function createFacet(Criteria $criteria, $min, $max) { $activeMin = $min; $activeMax = $max; /**@var $condition PriceCondition */ if ($condition = $criteria->getCondition('price')) { $activeMin = $condition->getMinPrice(); $activeMax = $condition->getMaxPrice(); } $label = $this->snippetManager->getNamespace('frontend/listing/facet_labels')->get('price', 'Price'); if (!($minFieldName = $this->queryAliasMapper->getShortAlias('priceMin'))) { $minFieldName = 'priceMin'; } if (!($maxFieldName = $this->queryAliasMapper->getShortAlias('priceMax'))) { $maxFieldName = 'priceMax'; } return new RangeFacetResult('price', $criteria->hasCondition('price'), $label, (double) $min, (double) $max, (double) $activeMin, (double) $activeMax, $minFieldName, $maxFieldName, [], 'frontend/listing/filter/facet-currency-range.tpl'); }
/** * @param Group[] $groups * @param int[] $actives * @return FacetResultGroup */ private function createCollectionResult(array $groups, $actives) { $results = []; if (!($fieldName = $this->queryAliasMapper->getShortAlias('sFilterProperties'))) { $fieldName = 'sFilterProperties'; } foreach ($groups as $group) { $items = []; $useMedia = false; $isActive = false; foreach ($group->getOptions() as $option) { $listItem = new MediaListItem($option->getId(), $option->getName(), in_array($option->getId(), $actives), $option->getMedia()); $isActive = $isActive || $listItem->isActive(); $useMedia = $useMedia || $listItem->getMedia() !== null; $items[] = $listItem; } if ($useMedia) { $results[] = new MediaListFacetResult('property', $isActive, $group->getName(), $items, $fieldName); } else { $results[] = new ValueListFacetResult('property', $isActive, $group->getName(), $items, $fieldName); } } return new FacetResultGroup($results, null, 'property'); }