0
A
回答
0
以下代碼可幫助我過濾客戶。
$customers = Mage::getResourceModel('customer/customer_collection')
->addAttributeToSelect('*')
->addAttributeToFilter('firstname', $firstName)
0
$customers = Mage::getResourceModel('customer/customer_collection') ->addAttributeToSelect('*') ->addAttributeToFilter('firstname', $firstName)
上面的代碼將只加載集合。
要通過名字獲取客戶詳細信息,我們需要遍歷客戶收集對象,然後獲取客戶ID。最後只加載單個客戶對象,如下
$model = Mage::getSingleton('customer/customer');
$customerCollection = $model->getCollection()
->addAttributeToSelect('*')
->addAttributeToFilter('firstname', array('like' => $variableFirstName));
foreach($customerCollection as $customerObject)
{
$customer = $model->load($customerObject->getId());
echo '<b>'.$customer->getFirstname() . $customer->getLastname().'</b><br/>';
}
在情況下,如果我們想通過名字來過濾,只需更改到
->addAttributeToFilter('lastname', array('like' => $variableLastName))
相關問題
- 1. 如何通過自定義分類的自定義字段篩選數據
- 2. 篩選通過自定義陣列
- 3. 通過出口客戶導出自定義Magento字段
- 4. kustomer API通過自定義字段獲取客戶請求
- 5. 通過自定義字段
- 6. Bigcommerce API客戶自定義字段
- 7. 如何通過自定義字段值篩選新的WP查詢?
- 8. 如何通過WCF將自定義異常的字段傳播到客戶端?
- 9. 篩選[字符串]]自定義範圍
- 10. 通過自定義字段排序自定義文章[WCK]
- 11. 高級自定義字段:無法通過自定義字段查詢帖子
- 12. 篩選出比自定義日期字段更早的帖子
- 13. Outlook使用MAPI自定義字段篩選
- 14. 使用高級自定義字段篩選和排序wordpress get_posts
- 15. Drupal 7,通過自定義字段值列出用戶
- 16. Log4j2自定義篩選器
- 17. 如何通過API設置複選框自定義字段
- 18. 如何篩選來自客戶端
- 19. 經過行篩選後的新客戶
- 20. 如何通過mysql插入自定義字段和字段值
- 21. 自定義客戶端複選框列
- 22. Kendo Grid自定義客戶端過濾
- 23. 通過字段中的子字符串篩選文檔
- 24. 添加自定義字段爲基本客戶端集成選項
- 25. 基於客戶端選擇的模板中的動態自定義字段
- 26. 如何向magento中的客戶添加自定義複選框字段?
- 27. 通過數字自定義字段排序WordPress帖子
- 28. WooCommerce - 自定義用戶註冊字段
- 29. Woocommerce自定義用戶輸入字段
目前尚不清楚問什麼。如果您需要一個客戶集合,只需使用'$ collection = Mage :: getResourceModel('customer/customer_collection');'作爲起點,然後您可以根據需要進行過濾;見http://www.magentocommerce.com/wiki/5_-_modules_and_development/catalog/using_collections_in_magento – benmarks 2011-12-28 13:09:28
是的本,其工作... – 2011-12-29 07:23:57