I'm writing search functionality in root magento file.
<?php
require_once('app/Mage.php');
umask(0);
Mage::app('default');
$collection = Mage::getModel('catalog/product')->getCollection();
$searchKeyword = 'kalmari123 abc'
$collection->addAttributeToFilter(
array(
array('attribute'=>'sku','like'=>"%$searchKeyword%"),
array('attribute'=>'name','like'=>"%$searchKeyword%")
));
foreach ($collection as $_product)
{
echo $_product->getSku();
}
kalmari123 is the sku for product.
It's giving correct result if $searchKeyword = 'kalmari123';
but it shows nothing if I'm using $searchKeyword = 'kalmari123 abc'
. How can I make it work? I want to search if any of the given keyword is matching.