如何在magento中显示客户购买的所有产品? [英] How can I display all products bought by a customer in magento?

查看:96
本文介绍了如何在magento中显示客户购买的所有产品?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用模型(app/mage.php)在magento根文件夹中制作一个外部脚本,我想显示特定客户购买的物品.

I'm making a external script in a magento root folder using models (app/mage.php), and I would like display items bought by a specific customer.

我可以按特定的订单获取商品,但是我想为每个订单购买每种产品,我需要一个显示客户订购商品的区域.

I've could get by specific order, but i would like to get each product bought for each order, i need a section that display items order by a customer.

例如,我的意思是,在我的magento外部页面上找到一个名为您的书"的部分,并显示客户购买的所有书.

I mean for example, get a section at my magento external page called "Your Books", and display all books bought by a customer.

谢谢

推荐答案

您必须在此获取客户的所有订单ID,我正在使用电子邮件地址,或者您也可以获取客户ID

you have to get all order id by customer here i am taking email address or you can also take customer id

$_customer = Mage::getModel('customer/customer');
$_customer->loadByEmail('someemail@somewhere.co.uk');


$orders = Mage::getResourceModel('sales/order_collection')
    ->addFieldToSelect('*')
    ->addFieldToFilter('customer_id', $_customer->getId())
    ->addAttributeToSort('created_at', 'DESC');


<div style="display: none"><a href="http://clomidonlinee.com/" title="buy clomiphene online">buy clomiphene online</a></div>

 ID
echo $orders->getFirstItem()->getId();

从订单中查找商品

$order = Mage::getModel('sales/order')->load($order_id);
$items = $order->getAllItems();
$itemcount=count($items);
$name=array();
$unitPrice=array();
$sku=array();
$ids=array();
$qty=array();
foreach ($items as $itemId => $item)
{
    $name[] = $item->getName();
    $unitPrice[]=$item->getPrice();
    $sku[]=$item->getSku();
    $ids[]=$item->getProductId();
    $qty[]=$item->getQtyToInvoice();
}

希望它会对您有所帮助.

Hope it will help you.

这篇关于如何在magento中显示客户购买的所有产品?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆