This code is displaying only one product from each category, however I want it to display all products from each category in its own owl-carousel.
How can I fix this?
<?php
$categoryIds = array("3","5","6","12","7");
foreach($categoryIds as $categoryId){
$carouselcategoryProducts = $block->getCategoryProductsById($categoryId);
foreach ($carouselcategoryProducts as $carouselproduct) {
/*Get Thumbnail*/
$carouselimageBlock = $block->getLayout()->createBlock('MagentoCatalogBlockProductListProduct');
$carouselproductImage = $carouselimageBlock->getImage($carouselproduct, 'category_page_grid');
?>
<div class="owl-carousel owl-theme">
<h4 class="item">
<a href="<?php echo $carouselproduct->getProductUrl(); ?>">
<div class="product_row2">
<div class="product_column2">
<img class="product_img2" <?php echo $carouselproductImage->toHtml(); ?><i class="far fa-clone compare"></i>
<p class="product_title2"><?php echo $carouselproduct->getName(); ?></p>
<p class="product_price2">€ <?php echo $carouselproduct->getFinalPrice(); ?>,-</p>
</div>
</div>
</a>
</h4>
</div>
<?php
}
}
?>
2
Answers
Fixed the issue.
Correct code:
Correct Code:
$categoryIds = array(3,5,6,12,7);