# How do I use a custom finder with pagination?

**URL:** https://discourse.cakephp.org/t/how-do-i-use-a-custom-finder-with-pagination/2519
**Category:** Need Help
**Created:** [May 4, 2017, 2:05pm UTC](https://discourse.cakephp.org/t/how-do-i-use-a-custom-finder-with-pagination/2519 "2017-05-04T14:05:20Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![ACeS](https://avatars.discourse-cdn.com/v4/letter/a/2acd7d/32.png) [@ACeS](https://discourse.cakephp.org/u/ACeS)
#### Post date: [May 4, 2017, 2:05pm UTC](https://discourse.cakephp.org/t/how-do-i-use-a-custom-finder-with-pagination/2519/1 "2017-05-04T14:05:20Z")

</div>

I am guessing this is simple, but I can’t get it to work. I have created a custom finder, customlist, in the Car model and using  
`$this->Car->find('customlist');`  
returns exactly what I expect. But it needs to be used in this existing function:

```

public function index() {
$this->Car->recursive = 0;
if (!empty($this->request->query[‘search’])) {
$term = ‘%’ . $this->request->query[‘search’] . ‘%’;
$this->Paginator->settings[‘conditions’][‘OR’] = array(
‘Car.desc LIKE’ => $term,
‘Car.model LIKE’ => $term);
}
$this->set(‘Cars’, $this->paginate());
}
```

  
I tried adding ‘customlist’ as an argument for paginate, didn’t work.  
I tried adding the line  
`$this->Paginator->settings['findType'] = 'customlist';`  
just before the paginate line, that also didn’t work,  
How do I get this function to use my custom finder?  
(This is Cake 2.X)

Additional info:  
It appears that adding the findType line as described above, is close. I can see that the correct SQL statement has been executed. But the Cake log has this:

```
2017-05-04 19:09:49 Error: [Error] Unsupported operand types
Request URL: /cars
Stack Trace:
#0/media/sf_GIT/insight/app/Vendor/cakephp/cakephp/lib/Cake/Controller/Controller.php(1089): PaginatorComponent->paginate(Object(Car), Array, Array)
#1/media/sf_GIT/insight/app/Controller/CarsController.php(31): Controller->paginate()
#2[internal function]: CarsController->index()
#3/media/sf_GIT/insight/app/Vendor/cakephp/cakephp/lib/Cake/Controller/Controller.php(491): ReflectionMethod->invokeArgs(Object(CarsController), Array)
#4/media/sf_GIT/insight/app/Vendor/cakephp/cakephp/lib/Cake/Routing/Dispatcher.php(193): Controller->invokeAction(Object(CakeRequest))
#5/media/sf_GIT/insight/app/Vendor/cakephp/cakephp/lib/Cake/Routing/Dispatcher.php(167): Dispatcher->_invoke(Object(CarsController), Object(CakeRequest))
#6/media/sf_GIT/insight/app/webroot/index.php(98): Dispatcher->dispatch(Object(CakeRequest), Object(CakeResponse))
#7{main}
```
  
Line 31 refers to the paginate() line.

---

<div class="post-metadata">

### Author: ![ACeS](https://avatars.discourse-cdn.com/v4/letter/a/2acd7d/32.png) [@ACeS](https://discourse.cakephp.org/u/ACeS)
#### Post date: [May 5, 2017, 2:14pm UTC](https://discourse.cakephp.org/t/how-do-i-use-a-custom-finder-with-pagination/2519/2 "2017-05-05T14:14:03Z")

</div>

Ok, the only way I could get this to work was to move the custom query into the controller, using  
`$this->Paginator->settings = array(`  
While this works, it seem like a violation of MVC…

---

<div class="post-metadata">

### Author: ![Andrej](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/andrej/32/446_2.png) [@Andrej](https://discourse.cakephp.org/u/Andrej)
#### Post date: [May 8, 2017, 5:10pm UTC](https://discourse.cakephp.org/t/how-do-i-use-a-custom-finder-with-pagination/2519/3 "2017-05-08T17:10:58Z")

</div>

`findType` is what you need so I would advice to dig into why it’s not working in your case. Someone might be able to help you out if you pasted here your custom finder code.
