23.02.2015 Views

www.it-ebooks.info

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

However, we do need to make a change in the controller. We need to change the<br />

function from setResults() to setCustomerRegistries().<br />

The file location is app/code/local/Mdg/Giftregistry/controllers/<br />

SearchController.php. Refer to the following code:<br />

public function resultsAction()<br />

{<br />

$this->loadLayout();<br />

if ($searchParams = $this->getRequest()->getParam('search_<br />

params')) {<br />

$results = Mage::getModel('mdg_giftregistry/ent<strong>it</strong>y')-<br />

>getCollection();<br />

if($searchParams['type']){<br />

$results->addFieldToFilter('type_id',<br />

$searchParams['type']);<br />

}<br />

if($searchParams['date']){<br />

$results->addFieldToFilter('event_date',<br />

$searchParams['date']);<br />

}<br />

if($searchParams['location']){<br />

$results->addFieldToFilter('event_location',<br />

$searchParams['location']);<br />

}<br />

$this->getLayout()->getBlock('mdg_giftregistry.search.<br />

results')<br />

->setCustomerRegistries($results);<br />

}<br />

$this->renderLayout();<br />

return $this;<br />

}<br />

Finally, let's update the layout files by following these steps:<br />

1. Open mdg_giftregistry.xml.<br />

2. Add the following code inside <br />

(the file location is app/design/frontend/base/default/layout/mdg_<br />

giftregistry.xml):<br />

<br />

<br />

<br />

Chapter 4<br />

[ 129 ]<br />

<strong>www</strong>.<strong>it</strong>-<strong>ebooks</strong>.<strong>info</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!