php - How to get individual product related images in magento


I want to get each product related images which is not assign to product but want to show all related images in front-end.

enter image description here

foreach ($data['product'] as $product) { 

              $product_id         =  $product->getId();
              $product_name        =  $product->getName();
              $product_description    =  $product->getDescription();
              $product_price    =  $product->getPrice();

              $isporductImage   =  $product->getImage();
              $product_image   =  Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB, true) . "media/catalog/product" . $product->getImage();
              $isproductthumbnail = $product->getThumbnail();
              $product_thumbnail =  Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB, true) . "media/catalog/product" . $product->getThumbnail();
              $collectionimage  = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB, true) . "media/catalog/category/thumb/" . $data['collection']['image'];
              $productplaceholderImage = $this->getSkinUrl() . "whi/assets/images/whi_placeholder.png";


            <?php if ($isproductthumbnail != "") { ?>
                 <div >
                  <img src="<?php echo $product_thumbnail; ?>" alt="celeb" />

             <?php }elseif ($isporductImage != "") { ?>
                 <div >
                  <img src="<?php echo $product_image; ?>" alt="celeb" />
              <?php } else { ?>
                  <div >   
                   <img src="<?php echo $productplaceholderImage ?>" alt="celeb" />

              <?php } ?>

i want to show all related product images in this list.

 <ul class="outfit-images-cmt">
                <li><img src="<?php echo $this->getSkinUrl() ?>whi/assets/images/doll.png"></li>
                <li><img src="<?php echo $this->getSkinUrl() ?>whi/assets/images/doll.png"></li>
                <li><img src="<?php echo $this->getSkinUrl() ?>whi/assets/images/doll.png"></li>
                <li><img src="<?php echo $this->getSkinUrl() ?>whi/assets/images/doll.png"></li>



Try the below code for fetch all the gallery images:

$product_image_url_gallery = $product->getMediaGalleryImages();
$galleryURL = '';
echo '<ul class="outfit-images-cmt">';

foreach ($product_image_url_gallery as $image) {
  $galleryImage = Mage::helper('catalog/image')->init($product, 'image', $image->getFile());
   echo '<li><img src="'.$galleryURL.'"></li>'

echo '</ul>';

People are also looking for solutions to the problem: php - How to use insert query with select sub query and where clause?


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.