Skip to content

Commit

Permalink
BC break fix
Browse files Browse the repository at this point in the history
  • Loading branch information
bartoszpietrzak1994 committed Aug 14, 2018
1 parent da8f987 commit 8102395
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 8 deletions.
4 changes: 4 additions & 0 deletions app/config/config.yml
Expand Up @@ -68,3 +68,7 @@ liip_imagine:
web_path:
web_root: "%kernel.project_dir%/web"
cache_prefix: "media/cache"

sylius_shop:
product_grid:
include_all_descendants: true
21 changes: 14 additions & 7 deletions src/Sylius/Bundle/CoreBundle/Doctrine/ORM/ProductRepository.php
Expand Up @@ -75,22 +75,29 @@ public function createShopListQueryBuilder(
$queryBuilder = $this->createQueryBuilder('o')
->addSelect('translation')
->innerJoin('o.translations', 'translation', 'WITH', 'translation.locale = :locale')
->innerJoin('o.productTaxons', 'productTaxon')
->innerJoin('productTaxon.taxon', 'taxon');
->innerJoin('o.productTaxons', 'productTaxon');

if ($includeAllDescendants) {
$queryBuilder->andWhere('taxon.left >= :taxonLeft');
$queryBuilder->andWhere('taxon.right <= :taxonRight');
$queryBuilder
->innerJoin('productTaxon.taxon', 'taxon')
->andWhere('taxon.left >= :taxonLeft')
->andWhere('taxon.right <= :taxonRight')
->andWhere('taxon.root = :taxonRoot')
->setParameter('taxonLeft', $taxon->getLeft())
->setParameter('taxonRight', $taxon->getRight())
->setParameter('taxonRoot', $taxon->getRoot())
;
} else {
$queryBuilder->andWhere('productTaxon.taxon = :taxon');
$queryBuilder
->andWhere('productTaxon.taxon = :taxon')
->setParameter('taxon', $taxon)
;
}

$queryBuilder
->andWhere(':channel MEMBER OF o.channels')
->andWhere('o.enabled = true')
->setParameter('locale', $locale)
->setParameter('taxonLeft', $taxon->getLeft())
->setParameter('taxonRight', $taxon->getRight())
->setParameter('channel', $channel)
;

Expand Down
Expand Up @@ -58,6 +58,14 @@ public function getConfigTreeBuilder(): TreeBuilder
->end()
->end()
->end()
->arrayNode('product_grid')
->addDefaultsIfNotSet()
->children()
->booleanNode('include_all_descendants')
->defaultFalse()
->end()
->end()
->end()
->end()
;

Expand Down
Expand Up @@ -38,6 +38,10 @@ public function load(array $config, ContainerBuilder $container): void
$loader->load(sprintf('services/integrations/locale/%s.xml', $config['locale_switcher']));

$container->setParameter('sylius_shop.firewall_context_name', $config['firewall_context_name']);
$container->setParameter(
'sylius_shop.product_grid.include_all_descendants',
$config['product_grid']['include_all_descendants']
);
$this->configureCheckoutResolverIfNeeded($config['checkout_resolver'], $container);
}

Expand Down
Expand Up @@ -15,7 +15,7 @@ sylius_grid:
taxon: "expr:notFoundOnNull(service('sylius.repository.taxon').findOneBySlug($slug, service('sylius.context.locale').getLocaleCode()))"
locale: "expr:service('sylius.context.locale').getLocaleCode()"
sorting: "expr:service('request_stack').getCurrentRequest().get('sorting', [])"
includeAllDescendants: true
includeAllDescendants: "expr:parameter('sylius_shop.product_grid.include_all_descendants')"
sorting:
position: asc
limits: [9, 18, 27]
Expand Down

0 comments on commit 8102395

Please sign in to comment.