I have created custom attribute for featured product and fetched the product collection using object manager.

 $objectManager =  \Magento\Framework\App\ObjectManager::getInstance();        
 $priceHelper = $objectManager->create('Magento\Framework\Pricing\Helper\Data');

  $collection = $objectManager->create('\Magento\Catalog\Model\ResourceModel\Product\Collection')

   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.



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.