2016-08-29 29 views
0

如何通過客戶電話號碼過濾訂單集合? 這裏是我的嘗試:如何通過客戶電話過濾訂單集合?

$orders = Mage::getModel('sales/order')->getCollection() 
->addAttributeToFilter('customer_phone', array('like' => '%' . $_POST['filter_client_phone'] . '%'))->load(); 

還怎麼我可以通過一些屬性從發貨訂單的信息篩選訂單採集?

回答

0

您可以使用以下查詢過濾訂單集合 $addressTable=Mage::getSingleton("core/resource")->getTableName("sales/order_address"); $orders = Mage::getModel('sales/order')->getCollection(); $select=$orders->getSelect()->joinLeft(array('oa'=>$addressTable),'oa.parent_id=main_table.entity_id') ->where('oa.address_type=?','shipping') ->where('oa.telephone LIKE ?','%' . $_POST['filter_client_phone'] . '%');