Return to Snippet

Revision: 70921
at September 30, 2016 19:39 by Pidarasiya


Initial Code
$products = $this->Product->find('all', array(
  'fields' => array('id'),
  'conditions' => array('title in' => explode(" ", $query))
)->toArray();

$ids = array();
foreach ($products as $product) {
  $ids[] = $product['id'];
}

$this->paginate = [
  'limit' => 10,
  'conditions' => array(
    'id IN' => array_unique($ids) //to eliminate duplicate ids
  ),
];

$products = $this->paginate('Products');
$this->set('products', $products');

Initial URL
http://aerocoding.com/en/question/27/Using-cakephp-elastic-search-with-pagination

Initial Description
How do you use the elastic-search plugin with cake's native pagination?

Initial Title
cakephp elastic-search pagination

Initial Tags
cakephp

Initial Language
PHP