更改Magento的Upsell Slider以使用相关产品

时间:2013-10-15 13:15:51

标签: php magento

我有一个客户在“相关产品”部分而不是“追加销售”部分中意外添加了产品。我有一个名为upsell_slider.phtml的文件,它吐出以下内容:

<?php if(count($this->getItemCollection()->getItems())): ?>
<div class="box-collateral box-up-sell upsell-slider">
    <h2><?php echo $this->__('Fashion Statement') ?></h2>
    <?php  $this->setColumnCount(4); // uncomment this line if you want to have another number of columns. also can be changed in layout ?>
    <?php $this->resetItemsIterator(); ?>
    <?php
        $products_count = 0;
        while($this->getIterableItem()){
            $products_count++;
        }
    ?>
    <div <?php if ($products_count > 1): ?>id="block-upsell-slider"<?php else:?> class="no-slider" <?php endif; ?>>
    <ul class="products-grid carousel-ul" id="upsell-product-table">
    <?php $this->resetItemsIterator(); while ($_item=$this->getIterableItem()) : ?>
        <li class="item grid_3 alpha">
            <a class="product-image" href="<?php echo $_item->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_item->getName()) ?>"><img src="<?php echo $this->helper('catalog/image')->init($_item, 'thumbnail')->constrainOnly(TRUE)->keepAspectRatio(TRUE)->keepFrame(FALSE)->resize(420, null); ?>" <?php echo MAGE::helper('ThemeOptions/Retina')->getRetinaData('upsell', $_item); ?> alt="<?php echo $this->htmlEscape($_item->getName()) ?>" /></a>
            <div class="product-details">
                <h3 class="product-name"><a href="<?php echo $_item->getProductUrl() ?>"><?php echo $this->htmlEscape($_item->getName()) ?></a></h3>
            </div>
        </li>
    <?php endwhile; ?>
    </ul>
    </div>
    <?php if ($products_count > 1): ?>
    <div class = 'next'></div>
    <div class = 'prev unselectable'></div>
    <?php endif; ?>
</div>
<script type="text/javascript">
      /* Upsell Block Slider */
      if(jQuery('#block-upsell-slider').length) {
          jQuery('#block-upsell-slider').iosSlider({
           responsiveSlideWidth: true,
           snapToChildren: true,
           desktopClickDrag: true,
           infiniteSlider: true,
           /* navSlideSelector: '.sliderNavi .naviItem', */
           navNextSelector: '.box-up-sell .next',
           navPrevSelector: '.box-up-sell .prev'
         });
     }

     function upsell_set_height(){
        var upsell_height = 0;
        jQuery('#block-upsell-slider li.item').each(function(){
            if(jQuery(this).height() > upsell_height){
                upsell_height = jQuery(this).height();
            }
        })
        jQuery('#block-upsell-slider').css('min-height', upsell_height+2);
    }
    setTimeout(function(){
        upsell_set_height();
    }, 1000);
    jQuery(window).resize(function(){upsell_set_height();});
     /* Upsell Block Slider */
</script> 
<?php endif ?>

我不能为我的生活让它看看相关的产品,而不是追加销售的产品。

1 个答案:

答案 0 :(得分:0)

我有更好的解决方案。您可以使用一个查询转换加售中的相关产品。

UPDATE `catalog_product_link` SET `link_type_id` = 4 WHERE `link_type_id` = 1;

请注意。这将使所有相关产品转向加售 ......然后在尝试之前备份桌面。