diff --git a/docs/cookbook/shop/embedding-products.rst b/docs/cookbook/shop/embedding-products.rst index eed9604abce..be443cf8b7b 100644 --- a/docs/cookbook/shop/embedding-products.rst +++ b/docs/cookbook/shop/embedding-products.rst @@ -35,7 +35,7 @@ Your extending repository class should look like that: { return $this->createQueryBuilder('o') ->innerJoin('o.channels', 'channel') - ->andWhere('o.enabled = true') + ->andWhere('o.enabled = :enabled') ->andWhere('channel = :channel') ->innerJoin('o.productTaxons', 'productTaxons') ->addOrderBy('productTaxons.position', 'asc') @@ -43,6 +43,7 @@ Your extending repository class should look like that: ->andWhere('taxon.code = :code') ->setParameter('code', $code) ->setParameter('channel', $channel) + ->setParameter('enabled', true) ->setMaxResults($count) ->getQuery() ->getResult(); diff --git a/src/Sylius/Bundle/CoreBundle/Doctrine/ORM/PaymentMethodRepository.php b/src/Sylius/Bundle/CoreBundle/Doctrine/ORM/PaymentMethodRepository.php index 473b15f1b19..3894700d41d 100644 --- a/src/Sylius/Bundle/CoreBundle/Doctrine/ORM/PaymentMethodRepository.php +++ b/src/Sylius/Bundle/CoreBundle/Doctrine/ORM/PaymentMethodRepository.php @@ -32,9 +32,10 @@ public function createListQueryBuilder(string $locale): QueryBuilder public function findEnabledForChannel(ChannelInterface $channel): array { return $this->createQueryBuilder('o') - ->andWhere('o.enabled = true') + ->andWhere('o.enabled = :enabled') ->andWhere(':channel MEMBER OF o.channels') ->setParameter('channel', $channel) + ->setParameter('enabled', true) ->addOrderBy('o.position') ->getQuery() ->getResult() diff --git a/src/Sylius/Bundle/CoreBundle/Doctrine/ORM/ProductRepository.php b/src/Sylius/Bundle/CoreBundle/Doctrine/ORM/ProductRepository.php index ff282b10f7d..f2abe61c47f 100644 --- a/src/Sylius/Bundle/CoreBundle/Doctrine/ORM/ProductRepository.php +++ b/src/Sylius/Bundle/CoreBundle/Doctrine/ORM/ProductRepository.php @@ -87,9 +87,10 @@ public function createShopListQueryBuilder( $queryBuilder ->andWhere(':channel MEMBER OF o.channels') - ->andWhere('o.enabled = true') + ->andWhere('o.enabled = :enabled') ->setParameter('locale', $locale) ->setParameter('channel', $channel) + ->setParameter('enabled', true) ; // Grid hack, we do not need to join these if we don't sort by price @@ -128,10 +129,11 @@ public function findLatestByChannel(ChannelInterface $channel, string $locale, i ->addSelect('translation') ->innerJoin('o.translations', 'translation', 'WITH', 'translation.locale = :locale') ->andWhere(':channel MEMBER OF o.channels') - ->andWhere('o.enabled = true') + ->andWhere('o.enabled = :enabled') ->addOrderBy('o.createdAt', 'DESC') ->setParameter('channel', $channel) ->setParameter('locale', $locale) + ->setParameter('enabled', true) ->setMaxResults($count) ->getQuery() ->getResult() @@ -145,10 +147,11 @@ public function findOneByChannelAndSlug(ChannelInterface $channel, string $local ->innerJoin('o.translations', 'translation', 'WITH', 'translation.locale = :locale') ->andWhere('translation.slug = :slug') ->andWhere(':channel MEMBER OF o.channels') - ->andWhere('o.enabled = true') + ->andWhere('o.enabled = :enabled') ->setParameter('channel', $channel) ->setParameter('locale', $locale) ->setParameter('slug', $slug) + ->setParameter('enabled', true) ->getQuery() ->getOneOrNullResult() ; @@ -171,9 +174,10 @@ public function findOneByChannelAndCode(ChannelInterface $channel, string $code) $product = $this->createQueryBuilder('o') ->where('o.code = :code') ->andWhere(':channel MEMBER OF o.channels') - ->andWhere('o.enabled = true') + ->andWhere('o.enabled = :enabled') ->setParameter('channel', $channel) ->setParameter('code', $code) + ->setParameter('enabled', true) ->getQuery() ->getOneOrNullResult() ; diff --git a/src/Sylius/Bundle/CoreBundle/Doctrine/ORM/ShippingMethodRepository.php b/src/Sylius/Bundle/CoreBundle/Doctrine/ORM/ShippingMethodRepository.php index 5adc794cd91..d6fa0a9021b 100644 --- a/src/Sylius/Bundle/CoreBundle/Doctrine/ORM/ShippingMethodRepository.php +++ b/src/Sylius/Bundle/CoreBundle/Doctrine/ORM/ShippingMethodRepository.php @@ -50,10 +50,11 @@ public function findEnabledForZonesAndChannel(array $zones, ChannelInterface $ch protected function createEnabledForChannelQueryBuilder(ChannelInterface $channel): QueryBuilder { return $this->createQueryBuilder('o') - ->andWhere('o.enabled = true') + ->andWhere('o.enabled = :enabled') ->andWhere('o.archivedAt IS NULL') ->andWhere(':channel MEMBER OF o.channels') ->setParameter('channel', $channel) + ->setParameter('enabled', true) ; } } diff --git a/src/Sylius/Bundle/TaxonomyBundle/Doctrine/ORM/TaxonRepository.php b/src/Sylius/Bundle/TaxonomyBundle/Doctrine/ORM/TaxonRepository.php index 93811e3ce4f..d6df16c1151 100644 --- a/src/Sylius/Bundle/TaxonomyBundle/Doctrine/ORM/TaxonRepository.php +++ b/src/Sylius/Bundle/TaxonomyBundle/Doctrine/ORM/TaxonRepository.php @@ -40,10 +40,11 @@ public function findChildrenByChannelMenuTaxon(?TaxonInterface $menuTaxon = null ->addSelect('child') ->innerJoin('o.parent', 'parent') ->leftJoin('o.children', 'child') - ->andWhere('o.enabled = true') + ->andWhere('o.enabled = :enabled') ->andWhere('parent.code = :parentCode') ->addOrderBy('o.position') ->setParameter('parentCode', ($menuTaxon !== null) ? $menuTaxon->getCode() : 'category') + ->setParameter('enabled', true) ->getQuery() ->getResult() ; @@ -54,11 +55,12 @@ public function findOneBySlug(string $slug, string $locale): ?TaxonInterface return $this->createQueryBuilder('o') ->addSelect('translation') ->innerJoin('o.translations', 'translation') - ->andWhere('o.enabled = true') + ->andWhere('o.enabled = :enabled') ->andWhere('translation.slug = :slug') ->andWhere('translation.locale = :locale') ->setParameter('slug', $slug) ->setParameter('locale', $locale) + ->setParameter('enabled', true) ->getQuery() ->getOneOrNullResult() ;