diff --git a/src/Provider/ProductUrlProvider.php b/src/Provider/ProductUrlProvider.php index abdbaae..fad6f52 100644 --- a/src/Provider/ProductUrlProvider.php +++ b/src/Provider/ProductUrlProvider.php @@ -36,12 +36,16 @@ public function __construct( public function getItems(string $locale): array { - $products = $this->productRepository->findBy(['enabled' => true]); + $products = $this->productRepository->createListQueryBuilder($locale) + ->andWhere('o.enabled = :enabled') + ->setParameter('enabled', true) + ->getQuery() + ->getResult() + ; $items = []; /** @var ProductInterface $product */ foreach ($products as $product) { - $product->setCurrentLocale($locale); // To have translated name and slug with given locale $items[] = [ 'name' => $product->getName(), 'value' => $this->router->generate('sylius_shop_product_show', ['slug' => $product->getSlug(), '_locale' => $locale]), diff --git a/src/Provider/TaxonUrlProvider.php b/src/Provider/TaxonUrlProvider.php index 5ebcb48..4c0dac3 100644 --- a/src/Provider/TaxonUrlProvider.php +++ b/src/Provider/TaxonUrlProvider.php @@ -36,7 +36,14 @@ public function __construct( public function getItems(string $locale): array { - $taxons = $this->taxonRepository->findBy(['enabled' => true]); + $taxons = $this->taxonRepository->createListQueryBuilder() + ->andWhere('translation.locale = :locale') + ->andWhere('o.enabled = :enabled') + ->setParameter('locale', $locale) + ->setParameter('enabled', true) + ->getQuery() + ->getResult() + ; $items = []; /** @var TaxonInterface $taxon */ @@ -44,7 +51,6 @@ public function getItems(string $locale): array if ($taxon->isRoot()) { continue; } - $taxon->setCurrentLocale($locale); // To have translated name and slug with given locale $items[] = [ 'name' => $this->getTaxonFullName($taxon), 'value' => $this->router->generate('sylius_shop_product_index', ['slug' => $taxon->getSlug(), '_locale' => $locale]),