v12/10B (Heavily Modified)
Greetings,
Many merchants use multiple price columns, example: "Retail Price" and then a "Sales Price" column. Often times they only have a the "Sales Prices" column partially filled.
How can we have the import process first check the "Sales Prices" column and, if blank, then import the field in "Retail Prices" column - all on a per feed basis?
Thanks!
Hi David,
Is that missing an "else" in the code?
Also, will the sales price be "decimalised"?
Thanks!
Hi,
Whilst it looks like it could be an if/else statement, in this case it isn't - the IF statement overwrites the price field with the saleprice if set, and then decimalises the price as normal...
Cheers,
David.
--
PriceTapestry.com
Hi David,
Worked like a champ!
Thank you so much for the clarification and your excellent assistance!
Hi David,
Is there a way this can be added to an existing intall WITHOUT having all the products deleted when you hit "register" (after the install)?
Thanks!
Hello David,
Another thing - some merchants, for whatever reason, use 0.00 in the sale price column if the item is not on sale.
Is there a way when the script checks the Sales Price column, and it is either blank OR 0.00 (or less than .01) that it will take the price column?
Thanks!
Hi,
There's an easy mod to make the "Register" only button from Feed Registration Step 2 skip the DELETE part of the process. In includes/admin.php look for the following code beginning at line 37:
$sql = "DELETE FROM `".$config_databaseTablePrefix."products` WHERE filename = '".database_safe($filename)."'";
database_queryModify($sql,$insertId);
...and REPLACE with:
if(!isset($_POST["submit"]) || ($_POST["submit"] != "Register"))
{
$sql = "DELETE FROM `".$config_databaseTablePrefix."products` WHERE filename = '".database_safe($filename)."'";
database_queryModify($sql,$insertId);
}
To treat 0.00 as empty, in place of the mod described previously, use:
if ($importRecord["saleprice"] && ($importRecord["saleprice"]!="0.00"))
{
$importRecord["price"] = $importRecord["saleprice"];
}
$importRecord["price"] = tapestry_decimalise($importRecord["price"]);
Cheers,
David.
--
PriceTapestry.com
Hi David,
Thanks for mod!
On the 0.00 tweak - will that also take into consideration if a merchant uses a single 0 (zero) or .00?
Hi,
Ah - in that case probably best to use the built in decimalise function... have a go with:
if ($importRecord["saleprice"] && (tapestry_decimalise($importRecord["saleprice"])!="0.00"))
{
$importRecord["price"] = $importRecord["saleprice"];
}
$importRecord["price"] = tapestry_decimalise($importRecord["price"]);
Cheers,
David.
--
PriceTapestry.com
Hi David,
Replacing:
$sql = "DELETE FROM `".$config_databaseTablePrefix."products` WHERE filename = '".database_safe($filename)."'";
database_queryModify($sql,$insertId);
with:
if(!isset($_POST["submit"]) || ($_POST["submit"] != "Register"))
{
$sql = "DELETE FROM `".$config_databaseTablePrefix."products` WHERE filename = '".database_safe($filename)."'";
database_queryModify($sql,$insertId);
}
Doesn't appear to work. Still deletes the products in the db.
Suggestions?
Thanks!
Hi,
Try with just:
if ($_POST["submit"] != "Register")
{
$sql = "DELETE FROM `".$config_databaseTablePrefix."products` WHERE filename = '".database_safe($filename)."'";
database_queryModify($sql,$insertId);
}
Cheers,
David.
--
PriceTapestry.com
Hi David,
Still can't get it to stop deleting the existing products.
Suggestions?
Thanks!
Hi,
Whilst the mod (if working!) will not delete the actual product records; it will re-create the `feeds` record so until the next import the /admin/ home page will report 0 products - is that perhaps what you are seeing rather than a search for products from the feed that has been re-registered not returning any products?
If that's not the case; please could you try a control modification by making the replacement:
if (FALSE)
{
$sql = "DELETE FROM `".$config_databaseTablePrefix."products` WHERE filename = '".database_safe($filename)."'";
database_queryModify($sql,$insertId);
}
...that should _definitely_ not delete any products; then we can look at debugging why $_POST["submit"] doesn't appear to be in the global scope...
Thanks!
David.
--
PriceTapestry.com
A-ha! LOL...
Was looking in the ADMIN and saw no products. However, on the site the merchant and all products still existed (d'oh).
Ended up going with the mod before your last reply.
Thanks for your help AND clarification!
Hi,
Sure - if you first add "saleprice" as a new field as normal. This field can then be picked up within the import record handler in includes/admin.php and the logic you describe applied - look for the following code at line 325:
$importRecord["price"] = tapestry_decimalise($importRecord["price"]);
...and REPLACE with:
if ($importRecord["saleprice"])
{
$importRecord["price"] = $importRecord["saleprice"];
}
$importRecord["price"] = tapestry_decimalise($importRecord["price"]);
Cheers,
David.
--
PriceTapestry.com