Skip to content

Commit 01cc2ef

Browse files
committed
TASK: add enabled products filter logic also for products grid by taxon and products carousel by taxon element
1 parent 147a026 commit 01cc2ef

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/Renderer/ContentElement/ProductsCarouselByTaxonContentElementRenderer.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,13 @@ public function render(ContentConfigurationInterface $contentConfiguration): str
4949

5050
$products = $this->productRepository->findByTaxon($taxon);
5151

52+
$enabledProducts = array_filter($products, function (ProductInterface $product): bool {
53+
return $product->isEnabled();
54+
});
55+
5256
return $this->twig->render('@SyliusCmsPlugin/shop/content_element/index.html.twig', [
5357
'content_element' => $this->template,
54-
'products' => $products,
58+
'products' => $enabledProducts,
5559
]);
5660
}
5761
}

src/Renderer/ContentElement/ProductsGridByTaxonContentElementRenderer.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,13 @@ public function render(ContentConfigurationInterface $contentConfiguration): str
4949

5050
$products = $this->productRepository->findByTaxon($taxon);
5151

52+
$enabledProducts = array_filter($products, function (ProductInterface $product): bool {
53+
return $product->isEnabled();
54+
});
55+
5256
return $this->twig->render('@SyliusCmsPlugin/shop/content_element/index.html.twig', [
5357
'content_element' => $this->template,
54-
'products' => $products,
58+
'products' => $enabledProducts,
5559
]);
5660
}
5761
}

0 commit comments

Comments
 (0)