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 class Mage_Adminhtml_Model_Search_Order extends Varien_Object
00027 {
00028
00029 public function load()
00030 {
00031 $arr = array();
00032
00033 if (!$this->hasStart() || !$this->hasLimit() || !$this->hasQuery()) {
00034 $this->setResults($arr);
00035 return $this;
00036 }
00037
00038
00039 $collection = Mage::getResourceModel('sales/order_collection')
00040 ->addAttributeToSelect('*')
00041
00042 ->joinAttribute('billing_firstname', 'order_address/firstname', 'billing_address_id')
00043 ->joinAttribute('billing_lastname', 'order_address/lastname', 'billing_address_id')
00044 ->joinAttribute('billing_telephone', 'order_address/telephone', 'billing_address_id')
00045 ->joinAttribute('billing_postcode', 'order_address/postcode', 'billing_address_id')
00046
00047 ->joinAttribute('shipping_firstname', 'order_address/firstname', 'shipping_address_id')
00048 ->joinAttribute('shipping_lastname', 'order_address/lastname', 'shipping_address_id')
00049 ->joinAttribute('shipping_telephone', 'order_address/telephone', 'shipping_address_id')
00050 ->joinAttribute('shipping_postcode', 'order_address/postcode', 'shipping_address_id')
00051
00052 ->addAttributeToFilter(array(
00053 array('attribute'=>'increment_id', 'like'=>$this->getQuery().'%'),
00054 array('attribute'=>'billing_firstname', 'like'=>$this->getQuery().'%'),
00055 array('attribute'=>'billing_lastname', 'like'=>$this->getQuery().'%'),
00056 array('attribute'=>'billing_telephone', 'like'=>$this->getQuery().'%'),
00057 array('attribute'=>'billing_postcode', 'like'=>$this->getQuery().'%'),
00058
00059 array('attribute'=>'shipping_firstname', 'like'=>$this->getQuery().'%'),
00060 array('attribute'=>'shipping_lastname', 'like'=>$this->getQuery().'%'),
00061 array('attribute'=>'shipping_telephone', 'like'=>$this->getQuery().'%'),
00062 array('attribute'=>'shipping_postcode', 'like'=>$this->getQuery().'%'),
00063 ))
00064
00065 ->setCurPage($this->getStart())
00066 ->setPageSize($this->getLimit())
00067 ->load();
00068
00069 foreach ($collection as $order) {
00070 $arr[] = array(
00071 'id' => 'order/1/'.$order->getId(),
00072 'type' => 'Order',
00073 'name' => Mage::helper('adminhtml')->__('Order #%s', $order->getIncrementId()),
00074 'description' => $order->getBillingFirstname().' '.$order->getBillingLastname(),
00075 'form_panel_title' => Mage::helper('adminhtml')->__('Order #%s (%s)', $order->getIncrementId(), $order->getBillingFirstname().' '.$order->getBillingLastname()),
00076 'url' => Mage::helper('adminhtml')->getUrl('*/sales_order/view', array('order_id'=>$order->getId())),
00077 );
00078 }
00079
00080 $this->setResults($arr);
00081
00082 return $this;
00083 }
00084
00085 }
00086