Hi,
I’d like to search multiple items copied from excel. These skus are separated by empty space. Search result is always empty because each condition should be OR not AND. How can I change pagenate condition from AND to OR?
Query Result
SELECT *, ParentProduct
.id
FROM parent_products
AS ParentProduct
WHERE ParentProduct
.name
LIKE ‘%na301mo%’ AND ParentProduct
.name
LIKE ‘%gf001bh%’ AND ParentProduct
.name
LIKE ‘%cc302bf%’ LIMIT 10
search values
na301mo gf001bh cc302bf
Controller
if (empty($results)) {
$this->paginate[‘conditions’] = $this->ParentProduct->resetConditions($searchStr, ‘multi-skus’);
$results = $this->paginate(‘ParentProduct’);
}
Model
public function resetConditions($searchStr, $opt) {
if ($opt == ‘multi-skus’) {
$conditions = array();
$searchStr = preg_replace(’!\s+!’, ’ ‘, $searchStr);
$search_terms = explode(’ ', $searchStr);
foreach ($search_terms as $search_term) {
$conditions[] = array($this->name . ‘.sku LIKE’ => ‘%’ . $search_term . ‘%’);
}
}
}
Version. 1.3x
Please advise.
Thank you