Magento 如何在购物车页面下显示追加销售产品



我正在尝试在购物车页面下显示追加销售产品,但我无法找到我们如何做到这一点。 我可以在购物车页面下调用追加销售文件。 但是产品没有来.. 文件内的代码是:

<?php if(count($this->getItemCollection()->getItems())): ?>
<div class="box-collateral box-up-sell">
    <div class="box-title">
        <h2><?php echo $this->__('You may also be interested in the following product(s)') ?></h2>
    </div>
    <ul class="products-grid" id="upsell-product-list">
    <?php // $this->setColumnCount(5); // uncomment this line if you want to have another number of columns. also can be changed in layout ?>
    <?php $this->resetItemsIterator() ?>
    <?php for($_i=0;$_i<$this->getRowCount();$_i++): ?>
        <?php for($_j=0;$_j<$this->getColumnCount();$_j++): ?>
            <?php if($_link=$this->getIterableItem()): ?>
            <li class="item">
                <a href="<?php echo $_link->getProductUrl() ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($_link, 'small_image')->resize(135) ?>" width="135" height="135" alt="<?php echo $this->htmlEscape($_link->getName()) ?>" title="<?php echo $this->htmlEscape($_link->getName()) ?>" /></a>
                <h3 class="product-name"><a href="<?php echo $_link->getProductUrl() ?>"><?php echo $this->htmlEscape($_link->getName()) ?></a></h3>
                <?php echo $this->getReviewsSummaryHtml($_link) ?>
                <?php echo $this->getPriceHtml($_link, true, '-upsell') ?>
            </li>
            <?php endif; ?>
        <?php endfor; ?>
    <?php endfor; ?>
    </ul>
    <script type="text/javascript">decorateList('upsell-product-list', 'none-recursive')</script>
</div>
<?php endif ?>

如果有人有任何想法,请告诉我。

Magento默认会在购物车页面上显示交叉销售产品。如果您检查checkout.xml文件,您将看到它。

<block type="checkout/cart_crosssell" name="checkout.cart.crosssell" as="crosssell" template="checkout/cart/crosssell.phtml"/>

如果您想在购物车页面上显示追加销售,您需要创建一个自定义块,该块将从Mage_Checkout_Block_Cart_Crosssell类扩展。在您的自定义块中,更新_getCollection方法以使用追加销售而不是交叉销售产品,如下所示:

 protected function _getCollection()
    {
        $collection = Mage::getModel('catalog/product_link')->useUpSellLinks()
            ->getProductCollection()
            ->setStoreId(Mage::app()->getStore()->getId())
            ->addStoreFilter()
            ->setPageSize($this->_maxItemCount);
        $this->_addProductAttributesAndPrices($collection);
        Mage::getSingleton('catalog/product_status')->addSaleableFilterToCollection($collection);
        Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection);
        Mage::getSingleton('cataloginventory/stock')->addInStockFilterToCollection($collection);
        return $collection;
    }

最后通过布局更新添加您的追加销售块。您可以保留与交叉销售块相同的模板文件。

<checkout_cart_index>
    <reference name="content">
        <block type="module_namespace/upsell" name="checkout.cart.upsell" as="upsell" template="checkout/cart/crosssell.phtml"/>
    </reference>
</checkout_cart_index>

最新更新