PHP related blog, freelancer to hire!

How to access magento search results externally (Drupal, Joomla, Zend Framework, Symfony etc)

Blast Search Lucene module enables you to get superquick results delivered to external application

Options are:

1) if applications are on the same server you can simply include Magento code and use module method:

 

$queryText = 'stainless';
$storeId = 1;
$mageFilename = '../path_to_your_magento_document_root/app/Mage.php';
require_once $mageFilename;
umask(0);
$app = Mage::app('default');
$indexer = Mage::getModel('blastlucenesearch/blastlucenesearch');
$indexer->setStoreId($storeId);
$products_data= $indexer->getResultsForApi($queryText);
print_r($products_data);

 

2)use Webservices API to get products

Login to your admin

Go to System-> Webservices -> Roles

Create new role

Enter name and select resource (Php4u) – make sure that Resource access it is set to custom

 

Then create new user (System -> Webservices -> Roles)

Assign it to newly Created role

Save it

Then you can use Soap or XMLRPC to access search results

$client = new SoapClient('http://YOURDOMAIN/api/soap/?wsdl');
$session = $client->login('lucene', 'lucene'); // your api login details created before
$result = $client->call($session, 'php4u_blastlucene.search', array('sony', 1,)); // query text, store Id
print_r($result);
$client->endSession($session);

You can test it with our test website at http://magento.php4u.co.uk/api/soap/?wsdl