I have created custom attribute for featured product and fetched the product collection using object manager.
<?php
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$priceHelper = $objectManager->create('Magento\Framework\Pricing\Helper\Data');
$collection = $objectManager->create('\Magento\Catalog\Model\ResourceModel\Product\Collection')
->addAttributeToSelect('*')
->addAttributeToFilter('newest_product',['eq'=>1])
->addAttributeToFilter('status',\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED)
->load();
foreach ($collection as $product)
{
$pdata = $product->getData();
$store = $objectManager->get('Magento\Store\Model\StoreManagerInterface')->getStore();
$imageUrl = $store->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA) . 'catalog/product' . $product->getImage();
}
?>
Here $imageUrl Returns the full image of the Product while I want the image of 300X400
I am trying to get the 300X400 size image in $imageurl
code but not sure how to get the resized image. If you see the code, I have not used the helper method.
Need help to resize the product image to 300X400.
Any help would be appreciated.