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
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
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.
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
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.
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
Hi Adrian,
Sure - should just be case of REPLACEing
($product["price"] < $rows[1]["price"])
with:
($product["price"] <= $rows[1]["price"])
Cheers,
David.
--
PriceTapestry.com
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.