PDA

View Full Version : simple "searchProduct" code example...


daves
03-07-07, 01:09
Can someone give me a simple bit of code to return a list of products based on a simple search...?

Using this as my base code (this returns random hotpickproducts):

//new client
$oClient = new api_client();
//set the paremeters
$aHotPicksParams = array('iCategoryId'=> 0, 'sSort'=> 'random', 'iLimit'=> 10, 'iOffset'=> 0);
//make the SOAP call
$oHotPicks = $oClient->call('getHotPickProductList', $aHotPicksParams);
//get the products array
$aProducts = $oHotPicks->getHotPickProductListReturn;
//print each product name to the page
foreach ($aProducts as $oProduct) {
echo $oProduct->sName;
echo '<br />';
}


So what i am after is the code (like above) but that uses the "searchProduct" call with relevant parameter settings for a simple search.

Does this make sense to anyone!? I dont need any fancy output..just the basic product info returned and printed to screen....

Any ideas anyone!?

Cheers
Dave

daves
03-07-07, 01:34
Hi

I have found answer to above... but this has thrown up another question...

If i use these parameters:

$aproductSearchParams = array('sQuery'=> 'tooth brush', 'sSort'=> 'popular', 'iOffset'=> 0, 'iLimit'=> 10 );

...the resulting list of products is NOT the same as show in www.shopwindow.com if i search on the same words "tooth brush" with popularity chosen as sorting method.

Any ideas as to why Im getting different results returned? Am i missing some vital parameters from my set above?

Thanks again....
Dave

authcode
03-07-07, 09:01
There's two reasons I can think of but you might have already checked these:
1) You're searching in a different category.
2) You don't have the same merchants.

Having said that I do find minor differences between my site and shopwindow.com, particularly in the categories, that I've started threads about here but haven't yet had an answer from anyone.

daves
03-07-07, 17:45
Do I have to sign up to all mechants programs in order to get the products returned in my search results?

Does anyone know how to set the other parameters in this code below to make sure im not restricting searches to any particular category?

$aproductSearchParams = array('sQuery'=> 'tooth brush', 'sSort'=> 'popular', 'iOffset'=> 0, 'iLimit'=> 10 );

??

Dave

authcode
03-07-07, 18:53
I believe the search results will only contain products from merchants that are enabled in your Merchant Manager. Many need T&C confirmation and stuff before they will return results.

You can add an 'iCategoryId'=> x (where x = any category id) to your parameter list but depending on the call your making iCategoryId will probably default to 0 (all) so it's unlikey you're searching a different category.