Public Member Functions | |
load () |
Definition at line 28 of file Customer.php.
load | ( | ) |
Definition at line 30 of file Customer.php.
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 }