从客户数据中获取magento订单ID

时间:2013-04-22 09:47:02

标签: php sql magento collections

我在加入工作时遇到问题。我正在尝试将订单ID连接到客户电话号码,保存在sales_flat_order_address中。因此,使用sales/order加入集合,并根据变量和我的电话号码进行过滤。我已经尝试了各种各样的组合,但到目前为止我只得到错误,现在我已经删除了我的代码并将从头开始尝试。关于这个教程的任何想法或链接?

1 个答案:

答案 0 :(得分:0)

下面的小代码片段

$customer = Mage::getModel('customer/customer')->getCollection()
->addAttributeToFilter('attribute_code', value)->load();
//Here your attribute code is phone
$orderCollection = Mage::getModel(’sales/order’)->getCollection();
$orderCollection->getSelect()->where(’e.customer_id =’.$customer->getId()); 

:)