Jump to content

How to import a product manually


Recommended Posts

Hi everybody and excuse my english
I have a problem. I'm running eshop MusicServis with a DJ stuff. And I have a complete product list from another eshop (not mine). And I need to import theese products to prestashop, but theese products are in their own order and scheme. So I need to now, which tables and colls in prestashop's database I have to add to create a new product (classic item without any special features).
Thanks for all your answers.

Link to comment
Share on other sites

  • 1 month later...

parts of an import script I did some time ago for 1.2.1

mysql_query("INSERT INTO product SET
id_product='".$item['products_id']."',
id_tax='".$item['products_tax_class_id']."',
price='".$item['products_price']."',
active='".$item['products_status']."',
indexed=1,
date_add=NOW(),
date_upd=NOW()
") or die(mysql_error());



mysql_query("INSERT INTO product_lang SET
id_product='".$item['products_id']."',
id_lang='1',
description_short='".$item['products_description']."',
name='".$item['products_name']."',
link_rewrite='".clean($item['products_name'])."'
");



mysql_query("INSERT INTO image SET
id_product='".$item['products_id']."',
position=1,
cover=1
") or die(mysql_error());

$imgID = mysql_insert_id();

mysql_query("INSERT INTO image_lang SET
id_image='".$imgID."',
id_lang=1,
legend='".$item['products_name']."'
") or die(mysql_error());

mysql_query("INSERT INTO category_product SET
id_category='".$item['categories_id']."',
id_product='".$item['products_id']."'
") or die(mysql_error());

mysql_query("UPDATE product SET id_category_default='".$item['categories_id']."'
WHERE id_product='".$item['products_id']."'") or die(mysql_error());
} 



there are some more - attributes options etc... but you can easily manage with what you have above
!!! clean is a function that creates friendly urls - you can create something of your own if you are using mod_rewrite:

function clean($string) {
   $url = $string;
   $url = preg_replace('~[^\\pL0-9_]+~u', '-', $url); // substitutes anything but letters, numbers and '_' with separator
   $url = trim($url, "-");
   $url = iconv("utf-8", "us-ascii//TRANSLIT", $url); // TRANSLIT does the whole job
   $url = strtolower($url);
   $url = preg_replace('~[^-a-z0-9_]+~', '', $url); // keep only letters, numbers, '_' and separator
   return $url;
}

Link to comment
Share on other sites

×
×
  • Create New...