1. Add a search box field in your page collection:
<div class="rma-search"> <form action="<?php echo $this->getUrl('returns/rma/')?>" method="post"> <input type="text" name="order_increment_id" placeholder="Search by order number"/> <input type="submit" name="action" value="Search"/> </form> </div>
For listing as you can see there is a foreach loop for collection Like:
so you need to find out the collection location like in my case i found:
$collection = $this->getRmaCollection();
and the collection of function i found in list.php page Like:
Original code:
public function getRmaCollection() { if (!$this->_collection) { $this->_collection = Mage::getModel('rma/rma')->getCollection() ->addFieldToFilter('main_table.customer_id', $this->getCustomer()->getId()) ->setOrder('created_at', 'desc'); if ($order = $this->getOrder()) { $this->_collection->addFieldToFilter('order_id', $order->getId()); } } return $this->_collection; }
For Search functionality modified code
public function getRmaCollection() { $ordId = $this->getRequest()->getParam('order_increment_id'); if($ordId){ $ord = Mage::getResourceModel('sales/order_collection') ->addFieldToSelect('*') ->addAttributeToFilter('increment_id',array('like'=>'%'.$ordId.'%')) ->addFieldToFilter('customer_id', Mage::getSingleton('customer/session')->getCustomer()->getId()); foreach($ord as $o) { $ordIdNew[] = $o->getId(); } if (!$this->_collection) { $this->_collection = Mage::getModel('rma/rma')->getCollection() ->addFieldToFilter('main_table.customer_id', $this->getCustomer()->getId()) ->addFieldToFilter('main_table.order_id', array('in'=>$ordIdNew)); } } else{ if (!$this->_collection) { $this->_collection = Mage::getModel('rma/rma')->getCollection() ->addFieldToFilter('main_table.customer_id', $this->getCustomer()->getId()) ->setOrder('created_at', 'desc'); if ($order = $this->getOrder()) { $this->_collection->addFieldToFilter('order_id', $order->getId()); } } } return $this->_collection; }
0 Comments