1 。全部订单
$_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'
);
foreach
(
$orders
as
$order
){
echo
$order
->getId().
""
;
}
2. 最近一个订单
$_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'
)
->setPageSize(1);
echo
$orders
->getFirstItem()->getId();