+ Reply to Thread
Results 1 to 3 of 3
-
07-30-2012 10:41 AM #1
Link a merchant to their top seller
This is a continuation of the discussion here: http://community.prosperent.com/show...t=default+link
The code example below will search the trends endpoint for the most popular products from a specific merchant for a specific time period. We then hit the product endpoint to find and create a link for the top product.
What does this accomplish?
Sometimes you want a visitor to your site to go straight to a merchants site without having to perform a search or find a product. The problem? Most merchants don't supply a generic link to their home page that affiliates can use. In our case, we instead send the user to one of the merchants top selling products. A visitor is expecting to have to search the merchants site for the product they are looking for, at least this way we are getting them to a page for something popular.
PHP Code:<?php
$today = date("Ymd");
require_once('Prosperent_Api.php');
$prosperentApi = new Prosperent_Api(array(
'api_key' => 'APIKEYHERE',
'filterMerchant' => 'Zappos.com',
'commissionDateRange' => '20120701,$today'
));
//fetch the result
$prosperentApi->fetchTrends();
foreach ($prosperentApi->getFacets('productId') as $productId)
{
$productArray[] = $productId['value'];
}
require_once('Prosperent_Api.php');
$prosperentApi = new Prosperent_Api(array(
'api_key' => 'APIKEYHERE',
'filterProductId' => $productArray,
'page' => 1,
'limit' => 1
));
$results = $prosperentApi->fetch();
foreach ($prosperentApi->getData() as $record)
{
?>
<div>
<a href="<?=$record['affiliate_url']?>"><?=$record['merchant']?></a>
</div>
<?
}
?>
-
07-30-2012 10:47 AM #2
The above is just an example, but depending on how you are using the api, there are a few ways to do it. You can pass the filter an array, so you could hit the merchant endpoint, create an array of merchants, then pass that to the trends filterMerchant. The above code works well if you just have a single merchant on a page. We could use this on our merchant pages on theNetPool for example: http://thenetpool.com/store/6pm
-
08-04-2012 03:56 AM #3

Reply With Quote
