I have 2 custom blocks, one is loading a product collection from category ID and another one loading a single product from product ID.
My blocks extends the core Magento product list block (\Magento\Catalog\Block\Product\ListProduct).
My template is also a duplicate of the core template.
When calling $block->getImage($_product, $image);
It throws an error.
Unable to resolve the source file for 'frontend/_view/en_GB/Magento_Catalog/images/product/placeholder/.jpg
'
I've been debugging this for quite a while and can't get to the bottom of it.
When comparing it to the collection on a category list page everything seems identical. The products are the same and have all the same data (including an image).
Any suggestions would be massively helpful.
Code in the template:
$productImage = $block->getImage($_product, $image);
Code in the block:
use Magento\Catalog\Api\CategoryRepositoryInterface;
use Magento\Catalog\Model\Product;
class Category extends \Magento\Catalog\Block\Product\ListProduct
{
public function __construct(
\Magento\Catalog\Block\Product\Context $context,
\Magento\Framework\Data\Helper\PostHelper $postDataHelper,
\Magento\Catalog\Model\Layer\Resolver $layerResolver,
CategoryRepositoryInterface $categoryRepository,
\Magento\Framework\Url\Helper\Data $urlHelper,
array $data = []
) {
parent::__construct(
$context, $postDataHelper, $layerResolver, $categoryRepository, $urlHelper, $data
);
}
}
From further digging it seems to be something to do with a resize function that is called from getImage. Could this be something to do with xml?