I am making a web service in magento. I have created many web-service of magento project like login, register, etc in magento project. I am not using third party web-service (default magento webservice).
I am follow the step: just create folder in magento root directory(webservice) then after create file serach.php and write the code for searching:
require("../app/Mage.php");
Mage::app();
if (isset($_REQUEST['search_text']) && ($_REQUEST['search_text'] != "")) {
$text = $_REQUEST['search_text'];
} else {
$text = "";
}
$search = "%" . trim($text) . "%";
$collection->addCategoryFilter()->addAttributeToSelect('name')->addAttributeToFilter('name', array(
'like' => $search
));
echo "";
print_r($collection);
die;
I am getting the error:
Fatal error: Call to a member function getId() on a non-object in /home/demo/public_html/app/code/core/Mage/Catalog/Model/Resource/Product/Collection.php on line 700