【问题标题】:Magento add pager toolbar to wishlistMagento 将寻呼机工具栏添加到愿望清单
【发布时间】:2011-10-23 01:30:15
【问题描述】:

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

【问题讨论】:

  • @denny:为我遇到的相同问题 +1。

标签: magento pager


【解决方案1】:

danny (OP) 已经自行回答了问题。

引用:


好的,我找到了解决方案 here,但我也会将其发布在这里,以便更好地突出显示代码: 创建一个新模块并覆盖位于以下位置的愿望清单块: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');
    }  
}

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


注意:这绝对是OK to self-answer 你自己的问题。请把它作为一个真正的答案发布,但不是在问题或评论中。发布为真实答案有助于使“未回答”列表更加清晰(避免让其他人浪费时间)。

【讨论】:

  • @gowri 嘿 gowri,这在 magento 1.5.1.0 中对我有用,没有问题,你会遇到什么错误?
【解决方案2】:

您不需要创建新模块。只需在本地创建(带有文件夹):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 之后 :image example

在 Magento 版本上测试。 1.9.0.1

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-09
    • 2014-10-17
    相关资源
    最近更新 更多