6

是否可以将目录集合寻呼机用于愿望清单,如果可以,我如何将其实现到愿望清单中?

4

2 回答 2

5

丹尼(OP)已经自我回答了这个问题。

引用:


好的,我在这里找到了解决方案,但我也会在这里发布它以更好地突出显示代码:创建一个新模块并覆盖位于的愿望清单块:code/core/Mage/Wishlist/Block/Customer/Wishlist.php 并将以下内容添加到您的 Wishlist.php

class Company_Wishlist_Block_Customer_Wishlist extends Mage_Wishlist_Block_Customer_Wishlist
{
    protected function _prepareLayout()
    {
        parent::_prepareLayout();
        $pager = $this->getLayout()
                      ->createBlock('page/html_pager', 'wishlist.customer.pager')
                      ->setCollection($this->getWishlist());
        $this->setChild('pager', $pager);
        $this->getWishlist()->load();
        return $this;
    }
    public function getPagerHtml()
    {
        return $this->getChildHtml('pager');
    }  
}

现在添加到位于app/design/frontend/default/your_theme/template/wishlist/view.phtml的view.phtml<?php echo $this->getPagerHtml(); ?>的开头和/或结尾。这应该够了吧。


注意:自行回答您自己的问题是绝对可以的。请仅将其作为真实答案发布,而不是在问题或评论中发布。发布为真实答案有助于使“未答复”列表更加清晰(避免让其他人浪费时间)。

于 2011-10-05T13:18:39.653 回答
0

您不需要创建新模块。只需在本地创建(带有文件夹):app\code\local\Mage\Wishlist\Block\Customer\Wishlist.php。
并在 Wishlist.php 上输入以下代码

<?php class Mage_Wishlist_Block_Customer_Wishlist extends Mage_Wishlist_Block_Abstract {
/**
 * Preparing global layout
 *
 * @return Mage_Wishlist_Block_Customer_Wishlist
 */
protected function _prepareLayout()
{
    parent::_prepareLayout();
    $pager = $this->getLayout()->createBlock('page/html_pager', 'wishlist.customer.pager');
    $pager->setAvailableLimit(array(5=>5,10=>10,20=>20,'all'=>'all'));
    $pager->setCollection($this->getWishlist());
    $this->setChild('pager', $pager);
    $this->getWishlist()->load();
    return $this;
}

/**
 * Pager HTML
 *
 * @return HTML
 */
public function getPagerHtml()
{
    return $this->getChildHtml('pager');
}

}

之后在 /app/design/frontend/base/default/template/wishlist/view.phtml 中添加以下代码

<?php echo $this->getPagerHtml(); ?>

在 view.phtml 末尾的 title div 和 formkey 之后:图像示例

在 Magento 版本上测试。1.9.0.1

于 2015-06-16T10:58:27.377 回答