如何在magento 1.9中为心愿单产品添加分页

时间:2018-10-23 07:43:59

标签: magento-1.9

我正在尝试逐页获取产品以进行收藏。我在下面的代码中获得了产品集合的计数。我已将页面大小设置为1,但显示的产品数量为2。请帮助我解决此问题。谢谢。

                    $wishlist1 = Mage::getModel('wishlist/wishlist')->loadByCustomer($customer, true)
                        ->setCurPage($page_num)
                        ->setPageSize(1)
                        ->load();

                foreach($wishlist1->getItemCollection() as $product){
                    $_product = Mage::getModel('catalog/product')->load($product['product_id']);//product id here
                    echo $product['product_id'];
                }

1 个答案:

答案 0 :(得分:0)

请尝试使用以下代码:

<?php
$customer = Mage::getModel("customer/customer")->setWebsiteId(Mage::app()->getStore()->getWebsiteId())->loadByEmail('mohit@streammarket.co.uk');
$wishlistItems = Mage::getModel('wishlist/item')->getCollection()
                ->setWebsiteId($customer->getWebsiteId())
                ->setCustomerGroupId($customer->getGroupId())
                ->setCurPage(1)
                ->setPageSize(1)
                ->load();
?>