0

I want to get all product images in modal for slider. So that if product view modal is opened, the it should contain all images to swipe.(on product view page)

<?php $items = $this->getItems();?>
<?php $thumbnails = $this->getGalleryImages();?>


<div class="container slick-modal-block">
    <ol class="related-product-list shop-related-slick">
        <?php foreach ($items as $item): ?>
            <li class="related-product-list_item media">
                <div class="pdp-grid">
                    <div class="col-1">
                        <div class="pdp-media">
                            <?php if (count($thumbnails) > 0): ?>
                                <?php
                                // GravDept:
                                $photoswipeIndex = 0;
                                ?>
                                <ul class="thumbnail-list">
                                <?php foreach ($thumbnails as $thumbnail): ?>
                                    <li class="thumbnail-list_item">
                                        <a
                                        class="product-image thumbnail-list_link"
                                        href="<?php echo $this->helper('catalog/image')->init($item, 'image', $thumbnail->getFile()); ?>"
                                        title="<?php echo Mage::helper('core')->quoteEscape($thumbnail->getLabel()); ?>"data-photoswipe-index="<?php echo $photoswipeIndex; ?>">
                                            <img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $thumbnail->getFile())->resize(60); ?>" alt="<?php echo $this->escapeHtml($thumbnail->getLabel()); ?>">
                                        </a>
                                    </li>
                                    <?php $photoswipeIndex++; ?>
                                <?php endforeach; ?>
                            </ul>
                            <?php endif; ?>
                        </div>
                    </div>
1

Try with below code.

<div class="container slick-modal-block">
    <ol class="related-product-list shop-related-slick">
        <?php foreach ($items as $item): ?>
            <li class="related-product-list_item media">
                <div class="pdp-grid">
                    <div class="col-1">
                        <div class="pdp-media">
                        <?php 
                            $tmpProduct = Mage::getModel("catalog/product")->load($item->getId());
                            $thumbnails = $tmpProduct->getMediaGalleryImages(); ?>
                            <?php if (count($thumbnails) > 0): ?>
                                <?php
                                // GravDept:
                                $photoswipeIndex = 0;
                                ?>
                                <ul class="thumbnail-list">
                                <?php foreach ($thumbnails as $thumbnail): ?>
                                    <li class="thumbnail-list_item">
                                        <a
                                        class="product-image thumbnail-list_link"
                                        href="<?php echo $this->helper('catalog/image')->init($item, 'image', $thumbnail->getFile()); ?>"
                                        title="<?php echo Mage::helper('core')->quoteEscape($thumbnail->getLabel()); ?>"data-photoswipe-index="<?php echo $photoswipeIndex; ?>">
                                            <img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $thumbnail->getFile())->resize(60); ?>" alt="<?php echo $this->escapeHtml($thumbnail->getLabel()); ?>">
                                        </a>
                                    </li>
                                    <?php $photoswipeIndex++; ?>
                                <?php endforeach; ?>
                            </ul>
                            <?php endif; ?>
                        </div>
                    </div>
  • but get model in for each is not good practice :( Please update!ASAP – Sushant Thorat Jul 31 '17 at 7:16
  • @SushantThorat, It is required to load a product because in related product block, there is no images detail available. To get all images, you must create object of a product and then you can get its related images. – Jaimin Sutariya Jul 31 '17 at 7:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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