Hoi David,
I want to maintain the clicks on products i did it in a simple way but everytime if i load the xml again the clicks are destroyed do you have a solution for me.
and when do you have time for my question about the advanced dropdown menu.
Thnx
Hi David i made the database adjustment and put
-id
-click
-product_name
-merchant
and in jump i made the next difference
require("includes/common.php");
$id = (isset($_GET["id"])?tapestry_normalise($_GET["id"],":\."):"");
$merchant = (isset($_GET["merchant"])?tapestry_normalise($_GET["merchant"],":\."):"");
$sql = "SELECT id,merchant,buy_url,search_name FROM `".$config_databaseTablePrefix."products` WHERE name='".database_safe($id)."' AND merchant='".database_safe($merchant)."'";
database_querySelect($sql,$rows);
$product = $rows[0];
$sql = "UPDATE `".$config_databaseTablePrefix."feeds` SET clicks=clicks+1 WHERE merchant = '".$product["merchant"]."'";
database_queryModify($sql,$insertID);
$result = mysql_query("SELECT product_name FROM clicks WHERE product_name='".$product["search_name"]."'");
$num = mysql_num_rows($result);
if(empty($num)) {
$sql = "INSERT INTO clicks SET product_name='".$product["search_name"]."', merchant='".$product["merchant"]."', click='1'";
database_queryModify($sql,$insertID);
}
else {
$sql = "UPDATE clicks SET click=click+1 WHERE product_name='".$product["search_name"]."' AND merchant='".$product["merchant"]."'";
database_queryModify($sql,$insertID);
}
header ("Location: ".$product["buy_url"]);
exit;
but how can i us this information like in the sorting of the products or in a top10 list pls help...
Hi,
Sorting of search results based on a table JOIN is complex and may have performance issues, which leads me to think it might be better to "back-fill" the clicks from your new table into the products table, in the same way that reviews are back-filled. This would be quite easy to do in your setup because you have the merchant name in your clicks table.
The code to do this could be patched into the admin_import() function, which is in includes/admin.php, starting at line 300. At the end of the function, you will see the following return statement:
return "";
CHANGE this as follows to update the products table from your clicks table. I'm assuming that from your previous version you still have a "clicks" column in your products table. If not, change the following code to whatever you have called this column.
$sql = "SELECT * FROM clicks WHERE merchant='".database_safe($admin_importFeed["merchant"])."'";
if (database_querySelect($sql,$clicks))
{
foreach($clicks as $click)
{
$sql = "UPDATE products SET clicks='".$click["click"]."' WHERE name='".".database_safe($click["product_name"])."."' AND merchant='".database_safe($admin_importFeed["merchant"])."'";
database_queryModify($sql,$result);
}
}
return "";
Because I don't have your setup i've not been able to test this, but it should point you in the right direction.
Cheers,
David.
Hi there,
During import; the first thing that happens is that all products for that merchant are deleted. The database is then completely refreshed with the latest product list. This is by far the simplest way to make sure that the product database matches the feed.
If you want to store a click per product; it is probably best to store it in a separate table rather than to update a column in the products table. This will also mean that clicks are per actual product rather than per product/merchant (although that may be what you want).
If you want the first way; I would suggest a table with:
ID
product_name
clicks
Or alternatively, to store merchant / product:
ID
merchant
product_name
clicks
Either way; on click-through, it's a simple task to update or isnert into this table. I normally do an UPDATE first, and if that returns zero records affected I then do an INSERT for the initial row - that's the most efficient way)...
Hope this helps,
Cheers,
David.