cancel
Showing results for 
Search instead for 
Did you mean: 

why data getting null from collection->addSearchFilter

why data getting null from collection->addSearchFilter

hi 

       $search = $this->_request->getParam('q');    
      print_r($search);
        $productdata  = $this->collection->addSearchFilter($search); 

@all  this code inside the my observer  event fire prefect but no result from the collection.

 

1 REPLY 1

Re: why data getting null from collection->addSearchFilter

Hello @sanjaymakw0653 

 

Check if the q Parameter is Being Passed Correctly

$search = $this->_request->getParam('q'); print_r($search); // This will display the search query

Verify That addSearchFilter is Supported by the Collection

Check the type of collection you're working with. Make sure that the collection is indeed a Product\Collection or that it extends the correct class that supports the addSearchFilter method.

$this->collection = $this->_productCollectionFactory->create();

Debugging the Collection

search = $this->_request->getParam('q'); 
$productdata = $this->collection->addSearchFilter($search); // Log the query for debugging 
$query = $productdata->getSelect()->__toString(); 
echo $query;

 

 

Hope it helps ! 

If you find our reply helpful, please give us kudos.

 

A Leading Magento Development Agency That Delivers Powerful Results, Innovation, and Secure Digital Transformation.

 

WebDesk Solution Support Team

Get a Free Quote | | Adobe Commerce Partner | Hire Us | Call Us 877.536.3789

 

 

Thank You,


WebDesk Solution Support Team
Get a Free Quote | Email | Adobe Commerce Partner | Hire Us | Call Us 877.536.3789


Location: 150 King St. W. Toronto, ON M5H 1J9