You are here:  » New report for preferred merchant product with more than one price

Support Forum



New report for preferred merchant product with more than one price

Submitted by paddyman on Sat, 2009-11-21 10:22 in

Hi David,

Sorry about the title !!

My question is a little hard to explain, so I'll give an example.

I would like to promote products for MerchantA via PPC as their commission is very good, but would only like to promote products where the prices are compared i.e. more than one price for the product.

Is it possible to have a report for MerchantA, only showing their products if more than one price exists, so I could identify which products to promote. I'm doing a lot of product mapping at the moment, so report would show products with exact matching title.

Don't know if this makes sense, or if its possible ??

Cheers

Adrian

Submitted by support on Sun, 2009-11-22 13:26

Hi Adrian,

Sure - have a go with something like this;

compared.php

<?php
  
require("includes/common.php");
  
header("Content-Type: text/plain");
  
$sql "SELECT * FROM `".$config_databaseTablePrefix."products`
            WHERE merchant='MerchantA'"
;
  
database_querySelect($sql,$products)
  foreach(
$products as $product)
  {
    
$sql "SELECT COUNT(*) AS numMerchants FROM `".$config_databaseTablePrefix."products`
              WHERE name='"
.database_safe($product["name"])."'";
    
database_querySelect($sql,$rows);
    if (
$rows[0]["numMerchants"] > 1)
    {
      print 
$product["name"]."\n";
    }
  }
?>

Cheers,
David.

Submitted by paddyman on Sun, 2009-11-22 14:44

Hi David,

Many thanks for this. Works great.

Any chance of extending it so there is a link to the product and also is it possible to only show products for MerchantA for which they have the cheapest price ?

Cheers

Adrian

Submitted by support on Sun, 2009-11-22 15:18

Hi Adrian,

Sure - have a go with;

<?php
  $merchantName 
"MerchantA";
  require(
"includes/common.php");
  
$sql "SELECT * FROM `".$config_databaseTablePrefix."products`
            WHERE merchant='"
.database_safe($merchantName)."'";
  
database_querySelect($sql,$products)
  foreach(
$products as $product)
  {
    
$sql "SELECT * FROM `".$config_databaseTablePrefix."products`
              WHERE name='"
.database_safe($product["name"])."' ORDER BY price ASC";
    if (
database_querySelect($sql,$rows) > 1)
    {
      
$product $rows[0];
      if (
         (
$product["merchant"] == $merchantName)
         &&
         (
$product["price"] < $rows[1]["price"])
         )
      {
        if (
$config_useRewrite)
        {
          
$href $config_baseHREF."product/".tapestry_hyphenate($product["name"]).".html";
        }
        else
        {
          
$href $config_baseHREF."products.php?q=".urlencode($product["name"]);
        }
        print 
"<a href='".$href."'>".$product["name"]."</a><br>";
      }
    }
  }
?>

So that you don't need to change the merchant name in more than one place just edit line 2 as required...

Cheers,
David.

Submitted by paddyman on Sun, 2009-11-22 17:53

Thanks yet again David :)

Adrian

Submitted by paddyman on Mon, 2009-11-23 18:53

Hi David,

One more thing on this.

For the previous code, how would I only show products with prices above a certain value (lets say £100) which MerchantA has ?

Many thanks

Adrian

Submitted by support on Tue, 2009-11-24 10:12

Hi Adrian,

To do that replace the first SQL statement...

  $sql = "SELECT * FROM `".$config_databaseTablePrefix."products`
            WHERE merchant='".database_safe($merchantName)."'";

...with:

  $sql = "SELECT * FROM `".$config_databaseTablePrefix."products`
            WHERE merchant='".database_safe($merchantName)."'
            AND price > 100.00";

Cheers,
David.

Submitted by paddyman on Wed, 2009-11-25 00:13

Thanks David,

Nice addition :)

Cheers

ADrian

Submitted by paddyman on Wed, 2010-12-08 07:58

Hi David,

The code above displays all products where a particular merchant has the cheapest price. It doesn't display a product if a few other merchants also are at the same price. Any way of changing so that all products are displayed, even when a competitor has the same "cheapest" price.

Hope this makes sense !!

Adrian

Submitted by support on Wed, 2010-12-08 09:23

Hi Adrian,

Sure - should just be case of REPLACEing

         ($product["price"] < $rows[1]["price"])

with:

         ($product["price"] <= $rows[1]["price"])

Cheers,
David.
--
PriceTapestry.com