将Color Switcher插件集成到Magento中 - Zoom&灯箱未显示切换图像

时间:2014-05-05 22:10:25

标签: javascript php magento

在Magento上,我正在整合color switcher plugin,当您从下拉菜单中选择颜色时它会起作用,但缩放和灯箱元素不显示切换的图像,而是显示默认产品图像。

以下是Media.phtml中的代码:

<p class="product-image">
    <a href="<?php echo $this->helper('catalog/image')->init($_product, 'image')->backgroundColor(array(255,255,255))->resize(638,900); ?>"  rel="<?php echo implode($config, ',');?>" title="<?php echo $this->escapeHtml($this->getImageLabel()) ;            
    echo $_helper->productAttribute($_product, $_img, 'image');?>" id="zoom1" class="cloud-zoom">   

    <?php
    echo '<img id="image" src="'.$this->helper('catalog/image')->init($_product, 'image')->backgroundColor(array(255,255,255))->resize(425,600).'" alt="'.$this->escapeHtml($this->getImageLabel()).'" title="'.$this->htmlEscape($this->getImageLabel()).'"/>';            
    echo $_helper->productAttribute($_product, $_img, 'image');
    ?></a>

<?php if (count($this->getGalleryImages()) > 0): ?>
 <a id="zoom-btn" class="lightbox-group zoom-btn-small" href="<?php echo $this->helper('catalog/image')->init($_product, 'image')->backgroundColor(array(255,255,255))->resize(638,900); ?>" title="<?php echo $this->getImageLabel(); ?>"><?php echo $this->__('Zoom'); ?></a>
 <?php endif; ?>

这是JavaScript:

<script type="text/javascript">
//<![CDATA[
    var assocIMG =  // Added  - Removed { here, causes issues with other scripts when not working with a configurable product.
    <?php 
    if ($_product->getTypeId() == "configurable") {
        echo "{";
        $associated_products = $_product->loadByAttribute('sku', $_product->getSku())->getTypeInstance()->getUsedProducts();
        foreach ($associated_products as $assoc)
            $dados[] = $assoc->getId().":'".($assoc->image == "no_selection" || $assoc->image == "" ? $this->helper('catalog/image')->init($_product, 'image', $_product->image)->resize(375,460) : $this->helper('catalog/image')->init($assoc, 'image', $assoc->image)->resize(375,460))."'";
    } else {
        $dados[] =  "''";
    }
    echo implode(',', $dados );     
    if ($_product->getTypeId() == "configurable") {
        echo "}";
    }
    ?> ;
//]]    
</script> 

我尝试在Zoom和Lightbox代码中集成图像ID,但是我没能使它工作,这是我尝试过的:

<?php if (count($this->getGalleryImages()) > 0): ?>
 <a id="zoom-btn" class="lightbox-group zoom-btn-small" href="<?php echo **'<img id="image" src="'.** $this->helper('catalog/image')->init($_product, 'image')->backgroundColor(array(255,255,255))->resize(638,900); ?>" title="<?php echo $this->getImageLabel(); ?>"><?php echo $this->__('Zoom'); ?></a>
 <?php endif; ?>

以下是我正在处理的页面:http://www.moramoraswimwear.com/magento/index.php/swimwear/view-all/test-4

为了获得正确的图像链接,我需要做什么?任何帮助都会非常感激。

0 个答案:

没有答案