繁体   English   中英

如何在magento中使用产品检索用户的愿望清单

[英]How to retrieve users wishlist with product in magento

我正在用magento编写REST API,以检索带有产品详细信息的用户的愿望清单。 下面的代码写为空结果。 有人可以建议出什么问题吗?

$customer = Mage::getSingleton('customer/session')->getCustomer();
$wishList = Mage::getSingleton('wishlist/wishlist')->loadByCustomer($customer);
$wishListItemCollection = $wishList->getItemCollection();

if (count($wishListItemCollection)) 
{
$arrProductIds = array();

foreach ($wishListItemCollection as $item) {
    /* @var $product Mage_Catalog_Model_Product */
    $product = $item->getProduct();
    $arrProductIds[] = $product->getId();
}

}

试试这个代码

$customer = Mage::getModel('customer/customer')->getCollection()->addAttributeToSelect('*');
$wishList = Mage::getSingleton('wishlist/wishlist')->loadByCustomer($customer);
$wishListItemCollection = $wishList->getItemCollection();

if (count($wishListItemCollection)) {
    $arrProductIds = array();

    foreach ($wishListItemCollection as $item) {
        /* @var $product Mage_Catalog_Model_Product */
        $product = $item->getProduct();
        $arrProductIds[] = $product->getId();
    }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM