I am trying to show Product Collection in .phtml file of custom module
<a href="<?= /* @escapeNotVerified */ $block->getProductUrl($_item) ?>" class="product photo product-item-photo">
<?= $block->getImage($_item, $image)->toHtml() ?>
</a>
in this line i am getting error as
Fatal error: Uncaught Error: Call to a member function toHtml() on
null
anyone please help
i got product Collection By Product ID
$this->_itemCollection=[];
foreach ($collection as $value) {
$product = $this->_productRepository->getById($value->getProductId());
array_push($this->_itemCollection, $product);
}
return $this;
Best Answer