You are here:  » Putting preferred merchant first

Support Forum



Putting preferred merchant first

Submitted by paddyman on Wed, 2008-12-03 07:44 in

Hi David,

I know there was previously a post on having merchant A (higher commission) appear above Merchant B when both are showing the same price. Tried searching and can't find it. Can you point me in the right direction?

Thanks

Adrian

Submitted by support on Wed, 2008-12-03 09:45

Hi Adrian,

I can't find it either i'm afraid but it's a straight-forward mod. The existing SQL to select products is in products.php at line 12:

    $sql = "SELECT * FROM `".$config_databaseTablePrefix."products` WHERE name = '".database_safe($q)."' ORDER BY price LIMIT ".$config_resultsPerPage;

...so if you replace that with:

    $sql = "SELECT *,
      CASE merchant
        WHEN 'Best Merchant' THEN 1
        WHEN 'Second Best Merchant' THEN 2
        ELSE 99
      END as preference
      FROM `".$config_databaseTablePrefix."products` WHERE name = '".database_safe($q)."'
      ORDER BY price,preference LIMIT ".$config_resultsPerPage;

This would mean you could actually rank your merchants in order of commission (just add more WHEN 'Merchant Name' THEN x etc. lines with increasing numbers so that you will always be promoting your favourite merchants above others for the same price.

Cheers,
David.

Submitted by paul30 on Wed, 2008-12-03 23:28

That is a VERY neat trick! - Thanks!!

Submitted by paddyman on Thu, 2008-12-04 11:52

Excellent, works great :)

Thanks

Adrian

Submitted by support on Thu, 2008-12-04 11:58

Cool!

Just a note to anybody implementing this - the best commission merchant isn't always the best converting! So it might be worth doing some tests to see who actually earns you the most regardless of their headline commission rate...

Cheers,
David.

Submitted by gunneradt on Thu, 2008-12-04 18:30

that very strange

I was just searching for the same thing and found this thread.

do we use the 'merchant name' as we have them in our merchant page?

Submitted by support on Thu, 2008-12-04 18:40

Hi,

Yes, the text in the SQL must match exactly the merchant name as you registered it - which will be the same as appears in the merchant page.

Cheers,
David.

Submitted by gunneradt on Thu, 2008-12-04 19:10

thanks very much

Submitted by marco on Fri, 2008-12-05 13:41

Hello,

Is something like this also possible for search page? e.g. putting preferred merchant(s) before other merchant when the relevance is the same?

Regards,
Marco.

Submitted by support on Fri, 2008-12-05 13:45

Hello Marco,

It shouldn't be a problem on the search page as products are grouped by name anyway; and the cheapest price will always be shown. The only situation in which I can see this helping is if products are actually the same but have slightly different names, in which case I would recommend using Product Mapping to make the names the same as a better alternative...

Cheers,
David.

Submitted by serviendo on Tue, 2009-10-13 13:48

Hi David

If I want to want to knock a merchant down the list because of poor conversion, would this work okay:

$sql = "SELECT *,
      CASE merchant
        WHEN 'Best Merchant' THEN 1
        WHEN 'Worst Merchant' THEN 99
        ELSE 98
      END as preference
      FROM `".$config_databaseTablePrefix."products` WHERE name = '".database_safe($q)."'
      ORDER BY price,preference LIMIT ".$config_resultsPerPage;

That way they would still show if there was no other merchant available (I restrict to 5 results when using PricesExternal.php), but not if there were more than 5 results.

Submitted by support on Tue, 2009-10-13 16:00

Yes - that should work fine!

Cheers,
David.

Submitted by atman on Wed, 2009-10-21 02:14

hi david.

Submitted by support on Wed, 2009-10-21 08:42

Hi atman,

If you wanted to add a new config variable, use something like:

  $config_bestMerchant = "Merchant Name";

...and then in the modification described above; instead of:

      CASE merchant
        WHEN 'Best Merchant' THEN 1
        WHEN 'Second Best Merchant' THEN 2
        ELSE 99

use:

      CASE merchant
        WHEN '".$config_bestMerchant."' THEN 1
        ELSE 99

Cheers,
David.

Submitted by paddyman on Fri, 2009-11-20 14:38

Hi David,

Trying to implement this in the new distribution.

Have changed code as follows, but getting product not found. Also using the totalprice mod which is working fine.

$sql = "SELECT *,
CASE merchant
WHEN 'HMV' THEN 1
WHEN 'Asda' THEN 2
ELSE 99
END as preference
(price+delivery) AS totalprice FROM `".$config_databaseTablePrefix."products` WHERE normalised_name = '".database_safe($q)."'
ORDER BY totalprice,preference LIMIT ".$config_resultsPerPage;

Any ideas ?

Thanks

Adrian

Submitted by support on Fri, 2009-11-20 20:08

Hi Adrian,

Just looks like a comma missing after "END as preference" - that should be all it is!

Cheers,
David.

Submitted by paddyman on Fri, 2009-11-20 20:44

Thanks David