hi david,
merchants' affiliate program is deactivated/reactivated all the time.
Is it possible to add a feature on the /admin control panel to enable or disable a specific mechant buy now links.
It would be a waste to totally remove the products from our PT store because it would most probably be listed on search engine already.
Rerards,
alex
Greetings,
Very interested in this.
Is it possible to:
1) Add another field in the "Registration Step 2" file, where by default, the merchant is Online/Active; but when we are notified they are Offline/Inactive we can select "Offline".
2) The merchant's feed(s)/products would remain active on the site.
3) When a user clicks on the jump link they are redirected to a page similar to the "Merchant" page (merchants.php)where we can add text to the $banner["h2"] = section announcing that this merchant is temporarily offline, please select another merchant" - or something of that nature.
We already use the following mod: http://www.pricetapestry.com/node/4670 so the registered feeds can easily be modified without losing products.
Something that can easily be accomplished?
Thanks!
Hi,
If you're happy to maintain a simple text file "offline.txt" containing a list of disabled merchants (one per line) then it could be done easily in jump.php without requiring any database modifications.
Firstly, look for the following code at line 4:
$sql = "SELECT filename,buy_url FROM `".$config_databaseTablePrefix."products` WHERE id='".database_safe($_GET["id"])."'";
...and REPLACE with;
$sql = "SELECT merchant,filename,buy_url FROM `".$config_databaseTablePrefix."products` WHERE id='".database_safe($_GET["id"])."'";
Next look for the following code at line 14:
header("Location: ".$product["buy_url"]);
...and REPLACE with:
$offline = file_get_contents("offline.txt");
if (strpos($offline,$product["merchant"])!==FALSE)
{
$product["buy_url"] = "offline.php";
}
header("Location: ".$product["buy_url"]);
Then create your offline.php page - a simple page based on the Price Tapestry header/footer would be as follows:
offline.php
<?php
require("includes/common.php");
require("html/header.php");
print "<p>Sorry, the link you requested is temporarily unavailable...</p>";
require("html/footer.php");
?>
Also possible to make a flag in the database if you'd like to do it that way instead, just let me know...
Hope this helps!
Cheers,
David.
--
PriceTapestry.com
Hi David,
Thanks!
Actually looking at your solution I see that it is better as under one domain we have multiple installs.
That being said, it is possible to have a common offline.txt outside the install directory, ie:
example.com/html/offline.txt as we have multiple installs, ie:
example.com/install-1
example.com/install-2
etc.
Thanks, again!
Hi,
Sure - all you need to do is make sure that the path to offline.txt is correct in this line:
$offline = file_get_contents("offline.txt");
...e.g:
$offline = file_get_contents("../html/offline.txt");
So if you've got a common /html/ directory at the top level the above will do the trick!
Cheers,
David.
--
PriceTapestry.com
Hi David,
Thanks - sometimes I just can't see the forest through the trees, lol.
Cheers!
Bob L.
This is a great mod David.
2 questions was wondering if possible with this.
1) Is it possible to use the offline.txt file to not show these merchants in the Merchant list.
2) Is it possible to grab the product name and use it in the amazon.php as a query to return suggested products as an alternative result set?
Thanks in advance.
Hi Bob,
To exclude merchants in offline.txt from the Merchant A-Z index, in merchants.php look for the following code at line 6:
$sql = "SELECT DISTINCT(merchant) FROM `".$config_databaseTablePrefix."products` ORDER BY merchant";
...and REPLACE with;
$offlineMerchants = file("offline.txt");
$notIns = array();
foreach($offlineMerchants as $offlineMerchant)
{
$notIns[] = "'".database_safe($offlineMerchant)."'";
}
$notIn = implode(",",$ins);
$sql = "SELECT DISTINCT(merchant) FROM `".$config_databaseTablePrefix."products` WHERE merchant NOT IN (".$notIn.") ORDER BY merchant";
Then to use amazon.php in your offline.php page, first where the buy_url is overloaded with the offline.php page by this code in the modification described above:
$product["buy_url"] = "offline.php";
...REPLACE that with:
$product["buy_url"] = "offline.php?id=".$_GET["id"];
And then to get the product name and use it in amazon.php, within your offline.php script add:
$sql = "SELECT name FROM `".$config_databaseTablePrefix."products` WHERE id='".database_safe($_GET["id"])."'";
if (database_querySelect($sql,$rows))
{
$q = $rows[0]["name"];
require("amazon.php");
}
Cheers,
David.
--
PriceTapestry.com
Bob L.
Thanks very much David,
I'll give these a try.
Bob L.
Hi David,
Hope all is well.
I figured the merchant.php out.
$offlineMerchants = file("offline.txt");
$notIns = array();
foreach($offlineMerchants as $offlineMerchant)
{
$notIns[] = "'".database_safe($offlineMerchant)."'";
}
$notIn = implode(",",$notIns);
$notIn = str_replace("\\n","",$notIn);
$sql = "SELECT DISTINCT(merchant) FROM `".$config_databaseTablePrefix."products` WHERE merchant NOT IN (".$notIn.") ORDER BY merchant";
Well spotted, Bob!
Alternatively, FILE_IGNORE_NEW_LINES can be added to the file() function, apologies for missing that...
$offlineMerchants = file("offline.txt",FILE_IGNORE_NEW_LINES);
$notIns = array();
foreach($offlineMerchants as $offlineMerchant)
{
$notIns[] = "'".database_safe($offlineMerchant)."'";
}
$notIn = implode(",",$ins);
$sql = "SELECT DISTINCT(merchant) FROM `".$config_databaseTablePrefix."products` WHERE merchant NOT IN (".$notIn.") ORDER BY merchant";
Cheers,
David.
--
PriceTapestry.com
Bob L.
A new situation has arrived.
This is where a merchant is off line on one network but not another.
Any idea on how to handle this situation?
Hello Bob,
Presumably the network + merchant combination can be identified as filename + merchant, so the offline.txt file can be extended, where each row contains
filename,merchant
Then in the modification to jump.php, where you have this line:
if (strpos($offline,$product["merchant"])!==FALSE)
...REPLACE that with:
if (strpos($offline,$product["filename"].",".$product["merchant"])!==FALSE)
Hope this helps!
Cheers,
David.
--
PriceTapestry.com
Bob L.
Hope all is well.
Sweet Mr. David.
Thank you very much.
Hi Alex,
This sort of thing would be very easy to implement as a code based modification - perhaps if you're happy to maintain a file containing an array of disabled merchants. The main question however is what you would like to happen in-place of those merchant's buy now links? Let me know how you'd like it to work and i'll work out the code for you...
Cheers,
David.