1
<?php
    $productCollection = Mage::getModel('catalog/product')
        ->getCollection() 
        ->addAttributeToFilter('name', array('like' => '%hp%'))
        ->addAttributeToSelect('*');

    foreach ($productCollection as $product) {
        //echo $product->getSku();
        echo "<ul><li>".$product->getName()."</li>
        <li>".$product->getDescription()."</li> </ul>";
        echo '<a href="'.Mage::getStoreConfig(Mage_Core_Model_Url::XML_PATH_SECURE_URL).'index.php/'.$product->getUrlPath().'"> 
        <img src="'.Mage::helper('catalog/image')->init($product, 'thumbnail')->resize(100).'"></a>';
    }
?>

The above code is making the path of an image is..

src="http://127.0.0.1/magento/media/catalog/product/cache/1/thumbnail/100x/9df78eab33525d08d6e5fb8d27136e95/images/catalog/product/placeholder/thumbnail.jpg"

but I want to get an image from this path.

media/catalog/product/and the Path of the image

How to get right path of image?

0
1

Try this code for getting original path

$productMediaConfig = Mage::getModel('catalog/product_media_config');
$baseImageUrl = $productMediaConfig->getMediaUrl($product->getImage());
$smallImageUrl = $productMediaConfig->getMediaUrl($product->getSmallImage());
$thumbnailUrl = $productMediaConfig->getMediaUrl($product->getThumbnail());

Reference

Not the answer you're looking for? Browse other questions tagged or ask your own question.