Hi David,
I was wondering if there were a way to import main products with a CSV (or XLS) file. I have full merchant catalog (with product names, description, ean, images) and it would be faster to import than to key. I can easily add category, brand columns and for alternatives products I found a way to scrape results with Imacro...
Thank you !
Bak
Hi David,
Yes, definitively !
I have such file under excel :
Brand | Brand Reference | Product name | Short description | Long description | EAN (not always)
and I can easily add category and image filename. Remains alternatives that I will automatically scrape...
Don't know if it makes sense for you, but I didn't find better solution to map neatly ten of thousands of products...
Thanks David
Bak
Hello Bak,
Sure - as the first configuration, make sure that the column names in your spreadsheet exactly match the field names (including case) on the pt_productsmap table, in other words, in row 1:
name | description | image_url | category | brand
Any additional fields should correspond with modifications to admin/productsmap_configure.php (example code in this thread - let me know if you're not sure how to modify for your particular fields) and further the corresponding custom field mods as per the standard instructions.
Next, use your spreadsheet program's Export or File Save As... function to create a .csv file ideally with the format Quoted Text - Header Row - Comma Separated (but if it's more convenient to use a different format, this can be changed in the call to MagicParser_parse() in the code below.
Save the CSV file in your site's /feeds/ folder with the filename "main.csv".
Finally, create a new file, paste in the following code and save as "scripts/importmain.php"
<?php
set_time_limit(0);
require("../includes/common.php");
require("../includes/MagicParser.php");
function myRecordHandler($record)
{
global $config_databaseTablePrefix;
$sets = array();
foreach($record as $k => $v)
{
if ($k=="name") continue;
$sets[] = "`".$k."` = '".database_safe($v)."'";
}
$set = implode(",",$sets);
$sql = "SELECT id FROM `".$config_databaseTablePrefix."productsmap` WHERE name='".database_safe($record["name"])."' LIMIT 1";
if (database_querySelect($sql,$rows))
{
$sql = "UPDATE `".$config_databaseTablePrefix."productsmap` SET ".$set." WHERE name='".database_safe($record["name"])."'";
}
else
{
$sql = "INSERT INTO `".$config_databaseTablePrefix."productsmap` SET ".$set.",name='".database_safe($record["name"])."'";
}
database_queryModify($sql,$result);
print $sql."\n";
}
MagicParser_parse($config_feedDirectory."main.csv","myRecordHandler","csv|44|1|34");
?>
Finally, browse to the new script /scripts/importmain.php to import /feeds/main.csv into the `pt_productsmap` table. It will update or insert as required, so any Alternatives configured for existing product mappings will be preserved.
Cheers,
David.
--
PriceTapestry.com
Thank you David ! I will make some tests next week...
Since there, I wish you a very happy festive season !
Best regards
Bak
Hello Bak,
Would your ideal scenario be to import your XML or CSV into Product Mapping (which can be modified easily if not already to include custom fields e.g. ean)?
This won't actually import anything into `pt_products`, but the details would be imported from the Product Mapping overrides as feeds are imported...
Cheers,
David.
--
PriceTapestry.com