0

On a lot of products, with swatch images, the main image is not showing anymore.

Anybody has an idea where I can find the "bug"?

Our Magento Version is: 1.9.1.1, and the swatch images extension we use are this:

http://www.magentocommerce.com/magento-connect/magento-color-swatches-extension.html

Kindly Simon

In this part, I not get my images from the products:

<a href="<?php echo $_item->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_item, 'small_image'), null, true) ?>" class="product-image" data-images-list="<?php echo $imgList; ?>">
                            <img src="<?php if(Mage::getStoreConfig('legenda_setting/category/aspect_ratio', $code)):?><?php echo $this->helper('catalog/image')->init($_item, 'small_image')->constrainOnly(FALSE)->keepAspectRatio(TRUE)->keepFrame(FALSE)->resize(350); ?><?php else: ?><?php echo $this->helper('catalog/image')->init($_item, 'small_image')->resize(Mage::getStoreConfig('legenda_setting/category/ratio_width', $code), Mage::getStoreConfig('legenda_setting/category/ratio_height', $code)); ?><?php endif; ?>" alt="<?php echo $this->stripTags($this->getImageLabel($_item, 'small_image'), null, true) ?>" /> </a>

And here is the hole code:

    <?php 
$store = Mage::app()->getStore();
$_helper = $this->helper('catalog/output');
$code  = $store->getCode();
$enable = Mage::getStoreConfig('filterproducts/config6/active',$code);
?>
<?php if($enable == 1 && $this->getItems()->getSize()): ?>
<div class="slider-latest-container">
    <div class="more-title">
        <h2 class="title"><span><?php echo Mage::getStoreConfig('filterproducts/config6/title',$code); ?></span></h2>
        <a href="<?php echo $this->getUrl('filterproducts/index/latest'); ?>" class="show-more-link"><?php echo $this->__('View More Products') ?></a>
    </div>
    <div class="products-slider items-slider latest-slider column<?php echo $this->get_product_column(); ?>">
        <ul class="products-grid">
            <?php foreach($this->getItems() as $_item): ?>
                <li class="item">
                    <div class="item-area">
                        <div class="product-image-wrapper <?php if (Mage::getStoreConfig('legenda_setting/category/effect_img', $code)): ?>hover-effect-slider"<?php endif; ?>>
                        <?php 
                            // Get the Special Price
                            $specialprice = Mage::getModel('catalog/product')->load($_item->getId())->getSpecialPrice(); 
                            // Get the Special Price FROM date
                            $specialPriceFromDate = Mage::getModel('catalog/product')->load($_item->getId())->getSpecialFromDate();
                            // Get the Special Price TO date
                            $specialPriceToDate = Mage::getModel('catalog/product')->load($_item->getId())->getSpecialToDate();
                            // Get Current date
                            $today =  time();

                            if ($specialprice){
                                if($today >= strtotime( $specialPriceFromDate) && $today <= strtotime($specialPriceToDate) || $today >= strtotime( $specialPriceFromDate) && is_null($specialPriceToDate)){
                                    if(Mage::getStoreConfig("legenda_setting/product_label/sale", $code)){
                        ?>
                                    <span class="label-icon sale-label">Sale!</span>
                        <?php       
                                    }
                                }
                            }
                        ?>
                        <?php
                            $now = date("Y-m-d");
                            $newsFrom= substr($_item->getData('news_from_date'),0,10);
                            $newsTo=  substr($_item->getData('news_to_date'),0,10);
                            if ($newsTo != '' || $newsFrom != ''){
                                if (($newsTo != '' && $newsFrom != '' && $now>=$newsFrom && $now<=$newsTo) || ($newsTo == '' && $now >=$newsFrom) || ($newsFrom == '' && $now<=$newsTo))
                                {
                                    if(Mage::getStoreConfig("legenda_setting/product_label/new", $code)){
                            ?> 
                                    <span class="label-icon new-label second-label">New!</span>
                            <?php 
                                    }
                                }
                            }
                        ?>
                        <?php 
                            $imgList = ''; 
                            if (Mage::getStoreConfig('legenda_setting/category/effect_img', $code)) {
                                $product = Mage::getModel('catalog/product')->load($_item->getId());
                                foreach ($product->getMediaGalleryImages() as $image) {
                                    // If no image, skip 
                                    if ($image->getFile() == NULL)
                                        continue;
                                    if (Mage::getStoreConfig('legenda_setting/category/aspect_ratio', $code)) {
        //                                $imgList .= Mage::helper('catalog/image')->init($_item, 'thumbnail', $image->getFile()).',';
                                        $imgList .= Mage::helper('catalog/image')->init($_item,'thumbnail',$image->getFile())->constrainOnly(FALSE)->keepAspectRatio(TRUE)->keepFrame(FALSE)->resize(350).',';   
                                    } else {
                                        $imgWidth = Mage::getStoreConfig('legenda_setting/category/ratio_width', $code);
                                        $imgHeight = Mage::getStoreConfig('legenda_setting/category/ratio_height', $code);
                                        $imgList .= Mage::helper('catalog/image')->init($_item,'thumbnail',$image->getFile())->resize($imgWidth, $imgHeight).',';
                                    }
                                }
                                $imgList = substr($imgList, 0, strlen($imgList) - 1);
                            }
                        ?>
                        <?php if(!$_item->isSaleable()): ?>
                            <span class="out-of-stock"><?php echo $this->__('Out of stock') ?></span>
                        <?php endif; ?>
                        <a href="<?php echo $_item->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_item, 'small_image'), null, true) ?>" class="product-image" data-images-list="<?php echo $imgList; ?>">
                            <img src="<?php if(Mage::getStoreConfig('legenda_setting/category/aspect_ratio', $code)):?><?php echo $this->helper('catalog/image')->init($_item, 'small_image')->constrainOnly(FALSE)->keepAspectRatio(TRUE)->keepFrame(FALSE)->resize(350); ?><?php else: ?><?php echo $this->helper('catalog/image')->init($_item, 'small_image')->resize(Mage::getStoreConfig('legenda_setting/category/ratio_width', $code), Mage::getStoreConfig('legenda_setting/category/ratio_height', $code)); ?><?php endif; ?>" alt="<?php echo $this->stripTags($this->getImageLabel($_item, 'small_image'), null, true) ?>" />
                        </a>
                        <?php if (Mage::getStoreConfig('quickview/general/enableview', $code)): ?>
                            <a href="<?php echo $_item->getId() ?>" class="sw-product-quickview"><?php echo $this->__('Quick View') ?></a>
                        <?php endif; ?>
                        </div>
                        <div class="description-wrapper">
                            <h3 class="product-name"><a href="<?php echo $_item->getProductUrl() ?>" title="<?php echo $this->stripTags($_item->getName(), null, true) ?>"><?php echo $_helper->productAttribute($_item, $_item->getName(), 'name') ?></a></h3>
                            <?php if($_item->getRatingSummary()): ?>
                            <?php echo $this->getReviewsSummaryHtml($_item, 'short') ?>
                            <?php endif; ?>
                            <?php echo $this->getPriceHtml($_item, true) ?>
                            <div class="actions">
                            <?php if(Mage::getStoreConfig('ajaxcart/addtocart/enablecategory')): ?>
                                <?php if($_item->isSaleable()): ?>
                                    <?php  if ( !($_item->getData('has_options') || $_item->isGrouped()) ) :  ?>
                                        <button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart btn-cart-<?php echo $_item->getId()?>" onclick="setLocationAjax('<?php echo $this->getAddToCartUrl($_item) ?>','<?php echo $_item->getId()?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
                                    <?php else: ?>
                                        <button type="button" title="<?php echo $this->__('Select Option') ?>" class="button btn-cart btn-cart-<?php echo $_item->getId()?>" onclick="showOptions('<?php echo $_item->getId()?>')"><span><span><?php echo $this->__('Select Option') ?></span></span></button>
                                        <a href='<?php echo $this->getUrl('ajaxcart/index/options',array('product_id'=>$_item->getId()));?>' class='fancybox' id='fancybox<?php echo $_item->getId()?>' style='display:none'>Options</a>
                                    <?php endif; ?>
                                <?php else: ?>
                                    <a href="<?php echo $_item->getProductUrl() ?>" class="button"><?php echo $this->__('Read More') ?></a>
                                <?php endif; ?>
                            <?php else: ?>
                                <?php if($_item->isSaleable()): ?>
                                    <button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_item) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
                                <?php endif; ?>
                            <?php endif; ?>

                            <?php if(Mage::getStoreConfig('ajaxcart/addtolinks/enablecategory')): ?>
                                <ul class="add-to-links">
                                    <?php if ($this->helper('wishlist')->isAllow()) : ?>
                                        <li><a href="#" onclick='ajaxWishlist("<?php echo $this->helper('wishlist')->getAddUrl($_item) ?>","<?php echo $_item->getId()?>");return false;' class="link-wishlist link-wishlist-<?php echo $_item->getId()?>"><?php echo $this->__('Add to Wishlist') ?></a></li>
                                    <?php endif; ?>
                                    <?php if($_compareUrl=$this->getAddToCompareUrl($_item)): ?>
                                        <li><span class="separator">|</span> <a href="#" onclick='ajaxCompare("<?php echo $_compareUrl ?>","<?php echo $_item->getId()?>");return false;' class="link-compare link-compare-<?php echo $_item->getId()?>"><?php echo $this->__('Add to Compare') ?></a></li>
                                    <?php endif; ?>                        
                                </ul>
                            <?php else: ?>
                                <ul class="add-to-links">
                                    <?php if ($this->helper('wishlist')->isAllow()) : ?>
                                        <li><a href="<?php echo $this->helper('wishlist')->getAddUrl($_item) ?>" class="link-wishlist button"></a></li>
                                    <?php endif; ?>
                                    <?php if($_compareUrl=$this->getAddToCompareUrl($_item)): ?>
                                        <li><a href="<?php echo $_compareUrl ?>" class="link-compare button"></a></li>
                                    <?php endif; ?>
                                </ul>
                            <?php endif; ?>
                            </div>
                        </div>
                    </div>
                </li>
            <?php endforeach; ?>
        </ul>
    </div>
</div>
<script type="text/javascript">
//<![CDATA[
    jQuery('.latest-slider .products-grid').owlCarousel({
        items: <?php echo $this->get_product_column() ?>,
        itemsDesktop: [1199, 3],
        itemsDesktopSmall: [991, 3],
        itemsTablet: [768, 2],
        itemsMobile: [479, 1],
        lazyLoad: true,
        pagination: false,
        navigation: true
    });
//]]>
</script>
<?php else: ?>
<div class="content-element">
    <div class="note-msg"><span class="msg-content"><?php echo $this->__('There are no products matching the selection.') ?></span></div>
</div>
<?php endif; ?>
  • 1
    update your questions with magento version and extension name which you are using for swatch if any. – Chirag Nandaniya Oct 7 '15 at 7:17
  • I tried to figure out more issue on my problem: – Simon Vetterli Oct 8 '15 at 12:34

Your Answer

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

Browse other questions tagged or ask your own question.