diff --git a/features/checkout/paying_for_order/seeing_payment_method_instructions_after_checkout.feature b/features/checkout/paying_for_order/seeing_payment_method_instructions_after_checkout.feature index 813c4f19b40..57b01ac0153 100644 --- a/features/checkout/paying_for_order/seeing_payment_method_instructions_after_checkout.feature +++ b/features/checkout/paying_for_order/seeing_payment_method_instructions_after_checkout.feature @@ -17,4 +17,4 @@ Feature: Seeing payment method instructions after checkout And I have product "PHP T-Shirt" in the cart When I proceed selecting "Offline" payment method And I confirm my order - And I should be informed with "Offline" payment method instructions + Then I should be informed with "Offline" payment method instructions diff --git a/src/Sylius/Bundle/ApiBundle/spec/Doctrine/QueryCollectionExtension/AvailableProductAssociationsInProductCollectionExtensionSpec.php b/src/Sylius/Bundle/ApiBundle/spec/Doctrine/QueryCollectionExtension/AvailableProductAssociationsInProductCollectionExtensionSpec.php index 756f1026c95..4a1b346e3dd 100644 --- a/src/Sylius/Bundle/ApiBundle/spec/Doctrine/QueryCollectionExtension/AvailableProductAssociationsInProductCollectionExtensionSpec.php +++ b/src/Sylius/Bundle/ApiBundle/spec/Doctrine/QueryCollectionExtension/AvailableProductAssociationsInProductCollectionExtensionSpec.php @@ -82,15 +82,19 @@ function it_filters_products_by_available_associations( $queryBuilder->getRootAliases()->willReturn(['o']); $queryBuilder->addSelect('o')->shouldBeCalled()->willReturn($queryBuilder); + $queryBuilder->addSelect('association')->shouldBeCalled()->willReturn($queryBuilder); $queryBuilder->leftJoin('o.associations', 'association')->shouldBeCalled()->willReturn($queryBuilder); + $expr->andX(Argument::type(Expr\Comparison::class), Argument::type(Expr\Comparison::class))->willReturn($andx); $expr->eq('associatedProduct.enabled', 'true')->shouldBeCalled()->willReturn($comparison); $expr->eq('association.owner', 'o')->shouldBeCalled()->willReturn($comparison); $queryBuilder->expr()->willReturn($expr->getWrappedObject()); $queryBuilder->leftJoin('association.associatedProducts', 'associatedProduct', 'WITH', Argument::type(Andx::class))->shouldBeCalled()->willReturn($queryBuilder); + $queryBuilder->andWhere('o.associations IS EMPTY OR associatedProduct.id IS NOT NULL')->shouldBeCalled()->willReturn($queryBuilder); $queryBuilder->andWhere('o.enabled = :enabled')->shouldBeCalled()->willReturn($queryBuilder); + $queryBuilder->setParameter('enabled', true)->shouldBeCalled()->willReturn($queryBuilder); $this->applyToCollection($queryBuilder, $queryNameGenerator, ProductInterface::class, 'get', []); diff --git a/src/Sylius/Bundle/CoreBundle/Doctrine/ORM/ProductRepository.php b/src/Sylius/Bundle/CoreBundle/Doctrine/ORM/ProductRepository.php index f1ed64e36fd..5403cc79811 100644 --- a/src/Sylius/Bundle/CoreBundle/Doctrine/ORM/ProductRepository.php +++ b/src/Sylius/Bundle/CoreBundle/Doctrine/ORM/ProductRepository.php @@ -251,8 +251,11 @@ public function findOneByChannelAndCodeWithAvailableAssociations(ChannelInterfac if (null === $product) { $product = $this->findOneByChannelAndCode($channel, $code); + if (null === $product) { + return null; + } - $product?->getAssociations()->clear(); + $product->getAssociations()->clear(); } $this->associationHydrator->hydrateAssociations($product, [