0

I'm trying to get all the product images of all the products in the shopping cart. I've used the following code:

$_item = $this->getItem();
$_product = Mage::getModel('catalog/product')->load($_item->getProductId());

foreach ($_product->getMediaGalleryImages() as $image) {
    echo var_export($image->getUrl());
    echo "<br>";
}

But this only displays all the images of the first produuct in the shopping cart. I've tried it this way:

foreach ($this->getMediaGalleryImages() as $image) {
    echo var_export($image->getUrl());
    echo "<br>";
}

But this doesn't return anything. How can I get all the images of all the products?

user3164891
  • 298
  • 2
  • 4
  • 14
  • where are you trying to do this? `$this` should be a value coming from an iteration (for example a `foreach()` over the cart-items). If you could explain exactly where you want this set of images, I could help you further – RichardBernards Nov 20 '14 at 08:42
  • I'm doing this in `default.phtml` which can be found in `checkout/cart/item` – user3164891 Nov 20 '14 at 08:43

1 Answers1

0

Use $this->getProductThumbnail()->resize(50,50) to retrieve the thumbnail image.

Use this example to get a different kind of image from the product:

$_product = $this->getItem()->getProduct();
Mage::helper('catalog/image')->init($_product, 'small_image')->resize(100,100);
RichardBernards
  • 3,146
  • 1
  • 22
  • 30