PDA

View Full Version : getMerchantList ?


authcode
01-04-07, 17:39
I'd like to be able to get a list of merchants that have products in a particular category - input iCategoryId get back merchant array with option to include descendants. Can't see an easy way to accomplish this with the current version unless I'm missing something obvious!

Andy
22-10-07, 12:51
Did you ever get a solution to this authcode?
If so, geez a clue! :)

Andy
22-10-07, 13:43
Okey dokey.

This is a BIG work around and Im not 100% sure of the results, but it might just do for me.

Ive got all the Category names and associated IDs in a DataBase table, so i looped through those to get their merchants.

Ive only done it with 10 of the 600+ categories so far, but I think it'll work for the rest.

Instead of getMerchant, i used getFeaturedMerchants and set the iLimit to 300

That should get every merchant that ever gets listed as featured on a category. Bear in mind that featured appears to be just a random list of the categories merchants, you'll see how this could work.

Heres the jist of it:






$sql = "SELECT catID, title FROM category_list ORDER BY catID ASC LIMIT 0, 10";
$result = mysql_query($sql) or die (mysql_error());

while($row = mysql_fetch_array($result, MYSQL_ASSOC)){

$catID = $row['catID'];


$params= array('iCategoryId' => $catID, 'iLimit' => 300, 'sSort' => 'az');

$response= $oClient->call('getFeaturedMerchants', $params);

echo '<b>'.$catID.' - '.$row['title'].'</b><ul>';

if(!empty($response)){
$x=1;
foreach ($response->getFeaturedMerchantsReturn as $merchant) {
$merchID = $merchant->iId;
$merchName = $merchant->sName;


echo '<li>'.$x.') '.$merchID.' - '.$merchName.'</li>';
$x++;
}
echo '</ul>';

}
}

returns a nice list i can read easily.
see it here. (http://www.quids-in-uk.co.uk/featuredList.htm)

I'll be making that store the lot in a DB later on for my own use.

But, it'd be nice to get some feed back on how accurate people think it may be first!

authcode
23-10-07, 09:07
Hi Andy,

No, I never got a response about this and I never pursued the idea further. In fact, I can't even remember what it was I was trying to do but it's not something I need now.

Good luck with your solution.

Andy
23-10-07, 16:02
Ah well authcode, you might need it again one day. So here's my discoveries:!

When I call getFeaturedMerchants with iListLimit=>300 I get a full list of retailers in each category.

but, getFeaturedMerchants doesn't allow any kind of sorting, which is a pain.


So, after hours of trawling the internet, I found this handy little function:

function objectSort($objectarray, $field)
{
for ($a=0;$a < (count($objectarray)); $a++)
{
for ($b=0;$b < (count($objectarray)); $b++)
{
if ($objectarray[$a]->$field < $objectarray[$b]->$field)
{
$temp = $objectarray[$a];
$objectarray[$a] = $objectarray[$b];
$objectarray[$b] = $temp;
}
}
}

return $objectarray;
}


Which Im using like this:

foreach (objectSort($response->getFeaturedMerchantsReturn, "sName") as $merchant) {
##Do the deeds to be done
}

This also allows me to dynamically serve the second field of objectSort by use of a $_GET[**], so I can easily switch to sorting by iId or whatever if I want.

Now to figure out how I can inject results from a database table into this lot!!