您的位置:首页 > 其它

Magento获得用户所有的订单、喜欢的产品

2015-02-10 14:23 459 查看
$orders = Mage::getResourceModel('sales/order_collection')
->addFieldToSelect('*')
->addFieldToFilter('customer_id', Mage::getSingleton('customer/session')->getCustomer()->getId())
->addFieldToFilter('state', array('in' => Mage::getSingleton('sales/order_config')->getVisibleOnFrontStates()))
->setOrder('created_at', 'desc');   //获得当前用户所有的订单

$items = $order->getAllItems();  //获得订单所有的子item

$items = $order->getAllVisibleItems(); //获得订单所有可见的子item

public function getWishlistProductId()  //获得用户所有喜欢、收藏的产品 wishlist
{
$customer = Mage::getModel('customer/customer')->getCollection()->addAttributeToSelect('*');

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

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

foreach ($wishListItemCollection as $item) {
$arrProductIds[] = $item->getProductId();
}
}
// Now here you can take that array and do what you want with it.
return $arrProductIds;
}
[/code]
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: