I want to add in Advanced Search possibility to search products by many sku-s. How to do it ?
In query it look like
sku=code&...
I want it to look like
sku=code,code,code$
or
sku=code;code;code&
Whether you are using an Ajax search or just the basic Magento search, you want to override the CatalogSearch AjaxController.php
or ResultController.php
. This way, it'll allow you to better manipulate the data you are receiving by getting the sku param like this :
$skus = $this->getRequest()->getParam('sku');
and then, build an array of conditions out of your sku's:
foreach (explode(',', $skus) as $sku)
{
$filters[] = array('attribute'=>'sku', 'like'=>'%'.$sku.'%');
}
when getting your product collection, you can use the previous filter like this:
$yourCollection->addAttributeToFilter($filters);
Then you should be good, hope this helps.
?sku[]=1&sku[]=2&sku[]=3
Commented
Mar 6, 2014 at 16:48