00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 class Mage_Adminhtml_Model_Search_Customer extends Varien_Object
00029 {
00030 public function load()
00031 {
00032 $arr = array();
00033
00034 if (!$this->hasStart() || !$this->hasLimit() || !$this->hasQuery()) {
00035 $this->setResults($arr);
00036 return $this;
00037 }
00038 $collection = Mage::getResourceModel('customer/customer_collection')
00039 ->addNameToSelect()
00040 ->joinAttribute('company', 'customer_address/company', 'default_billing', null, 'left')
00041 ->addAttributeToFilter(array(
00042 array('attribute'=>'firstname', 'like'=>$this->getQuery().'%'),
00043 array('attribute'=>'lastname', 'like'=>$this->getQuery().'%'),
00044 array('attribute'=>'company', 'like'=>$this->getQuery().'%'),
00045 ))
00046 ->setPage(1, 10)
00047 ->load();
00048
00049 foreach ($collection->getItems() as $customer) {
00050 $arr[] = array(
00051 'id' => 'customer/1/'.$customer->getId(),
00052 'type' => 'Customer',
00053 'name' => $customer->getName(),
00054 'description' => $customer->getCompany(),
00055 'url' => Mage::helper('adminhtml')->getUrl('*/customer/edit', array('id'=>$customer->getId())),
00056 );
00057 }
00058
00059 $this->setResults($arr);
00060
00061 return $this;
00062 }
00063 }