4
<?php foreach ($temp as $product): ?>

<?php
    $id = $product['entity_id'];
    $img = $product['image'];
    $url = $product['url_path'];
    $small_image = $skinUrl.$product['small_image'];
    $small_img_lable = $product['small_image_label'];
    $thumbnail = $product['thumbnail'];
    $name = $product['name'];
    $price = $product['price'];
    $special_price = $product['special_price'];
    $size = $product['size'];
?>

<li class="product-grid_item product-tile">
<a class="product-image" href="<?php echo $url; ?>">
<div class="quickview">
    <button class="button button--s button--inverted">Quick View</button>
</div>
   <picture class="pimg1">
       <source srcset="<?php echo $small_image; ?>" media="(min-width: 400px)">
       <img srcset="<?php echo $small_image; ?>" alt="<?php echo $small_img_lable;?>">
  </picture>
  <picture class="pimg2">
      <source srcset="<?php echo $thumbnail; ?>" media="(min-width: 400px)">
      <img srcset="<?php echo $thumbnail; ?>" alt="<?php echo $thumbnail;?>">
 </picture>

$temp contain product attributes.And i have all the attibute data in json file, but can't get image url. How can I get this ?

"small_image":"/1/_/1_4_1.jpg","thumbnail":"/1/_/1_4_1.jpg" this are my small image and thumbnail image values in json.

3 Answers 3

5

Try this :

$media = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
$imageUrl = $media.'catalog/product/'. $product['image'];
1
  • Thank you @ashish Jagnani. also i want only products that matches only current category in this listing page. Commented Jul 10, 2017 at 11:19
2

You can fetch like below.

$imageUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . 'catalog/product' . $product->getImage();
$imageCacheUrl = Mage::helper('catalog/image')->init($product, 'image')->resize(135,135);
$imageCacheUrl = Mage::helper('catalog/image')->init($product, 'small_image')->resize(100,100);
$imageCacheUrl = Mage::helper('catalog/image')->init($product, 'thumbnail')->resize(45,45);
1

Guess this is an unfixed "bug" in Magento where image attribute isn't added to flat product tables.

Fix: add <image> to app/code/core/Mage/Catalog/etc/config.xml

To get full image URLs you can also use

$image = $product->getImageUrl();
$small = $product->getSmallImageUrl();

But this will not work ... (another bug)

$thumb = $product->getThumbnailUrl();

Your Answer

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

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