Hi David,
I'm a bit lost with the following. I'm modifying PT to work as a hotel search comparison, and I'm almost there, just stuck with a couple of questions:
- I have added a couple of new fields, city and country, and import them from some xml's. The problem is, the names of the
cities and countries come sometimes in English (though the website and the rest of the xml's are in Spanish), and sometimes one xml would have the name of a city in English and another xml in Spanish, thus creating 2 different cities. So far, I've
created a php script that creates an array with all the names translated and then connects to the database and updates it,
which works fine, but it has a problem, everytime I import a xml I need to run the script manually. Is there a better way to
do it? Maybe a kind of 'city mapping' or 'country mapping' would be easier? Os is there a way to call this script so it runs
automatically after import?
- Sometimes the xml's come with not-so-accurate data, for example incomplete descriptions, descriptions in a different
language, with grammatical or spelling mistakes, etc. which I would need to correct as I find them. But, then again, if I
import the xml's, all the modifications are gone. Is there a way to prevent some fields not to be overwritten? What would
you recommend?
Hope you can shed some light on the topic.
Many thanks,
Charlie.
Hi David,
Thanks for the answer. I understand the first part about calling the cleansing script as part of an automations script.
However, the second part about description cleansing is not clear, could you please explain in more detail? I don't quite get
what you mean by maintaining the preferred descriptions indexed by (merchant+producto name).
It would be great when you could extend on that.
Cheers,
Charlie.
Hi Charlie,
Perhaps rather than modify the database after every import, it may be easier to implement the custom descriptions modification described here...
In terms of implementing it as a PHP script to run at post import (e.g. as part of your /scripts/cleansing.php), what I mean by indexing by merchant+product name is just how you would hold your custom descriptions and then use the merchant + product name to update the database. For example, consider the following PHP code that would implement such a method (assuming uploaded to the /scripts/ folder of your Price Tapestry installation):
<?php
require("../includes/common.php");
$myDescriptions["Merchant 1"]["Product 1"] =
"This is the custom description for Product 1 from Merchant 1";
$myDescriptions["Merchant 1"]["Product 4"] =
"This is the custom description for Product 4 from Merchant 1";
$myDescriptions["Merchant 1"]["Product 7"] =
"This is the custom description for Product 7 from Merchant 1";
$myDescriptions["Merchant 2"]["Product 5"] =
"This is the custom description for Product 5 from Merchant 2";
// etc. etc.
foreach($myDescriptions as $merchant => $products)
{
foreach($products as $name => $description)
{
$sql = "UPDATE `".$config_databaseTablePrefix."products`
SET
description = '".database_safe($description)."'
WHERE
merchant='".database_safe($merchant)."' AND name='".database_safe($name)."'";
database_queryModify($sql,$result);
}
}
?>
Hope this helps!
Cheers,
David.
Hi Charlie,
I think I would recommending combing your post-import cleansing scripts into a single process, and then set-up that script to run automatically after import. I assume you're set-up to use /scripts/import.php @ALL. If you're calling that as part of an automation script (e.g. downloading all feeds then importing), the easiest thing to do is probably to call in the same way, e.g.
/usr/bin/php /path/to/pricetapestry/scripts/import.php @ALL
/usr/bin/php /path/to/pricetapestry/scripts/cleanup.php
(where /scripts/cleanup.php is your post-import cleansing script)
City name fix-up you say you have working; regarding description cleansing, I would maintain your preferred descriptions indexed by (merchant+product name), that way your cleansing script can UPDATE ... WHERE merchant='Merchant Name' AND name='Product Name'
If you need any further help with the detail just let me know...
Cheers,
David.