[TYPO3-commerce] Importing existing Products

Karl-Ernst Kiel kekiel at kekiel.de
Thu Apr 24 12:13:58 CEST 2008


altoplan - Marco Schwarz wrote:
> I would like to import about 1000 products of an existing shop-system into
> commerce,

Hi Marco!

I wrote an import-script for tranfering data from a mediando database. 
Here are the basic steps along with some sql-statements (containing some 
customer-specific fields...).

Maybe this will help you...

Greetings,
Karl-E.


1.) Create categories

$sql = "INSERT INTO tx_commerce_categories 
(`pid`,`tstamp`,`crdate`,`cruser_id`,`sys_language_uid`,`l18n_parent`,`title`,`user_boplakatalog_id_o_tree_block`,`keywords`,`description`,`images`,`user_boplakatalog_downloadfiles`,`navtitle`) 
VALUES 
($catPid,$tstamp,$tstamp,".intval($crUser).",".intval($langId).",".intval($langParent).",'$newname',".intval($id_o_tree_block).",'".$keywords."','".$bText."','".$pics."','".$downloads."','$firstpic' 
)";

2.) Build the tree structure

$sql="INSERT INTO tx_commerce_categories_parent_category_mm 
(uid_local,uid_foreign,sorting) VALUES 
($myuid,".intval($myrow2['uid']).",".intval($myrow2['O_SEQUENCE']).");";

$sql="UPDATE tx_commerce_categories SET parent_category = 
".intval($myrow2['uid'])." ,sorting = ".intval($myrow2['O_SEQUENCE'])." 
WHERE uid = $myuid";

3.) Insert Products and Articles and Prices

$sql = "INSERT INTO tx_commerce_products 
(`pid`,`tstamp`,`crdate`,`cruser_id`,`sys_language_uid`,`l18n_parent`,`title`,`description`,`user_boplakatalog_id_o_product`,`images`,`attributes`,`user_boplakatalog_downloadfiles`,`user_boplakatalog_ordernumber`) 
VALUES 
($catPid,$tstamp,$tstamp,".intval($crUser).",".intval($langId).",".intval($langParent).",'$newname','$newsubtitle',".intval($id_o_product).",'$prodFileName','".mysql_escape_string($attrXML)."','$downloadFileName','$newartNr')"; 


$sql = "INSERT INTO tx_commerce_articles 
(`pid`,`tstamp`,`crdate`,`cruser_id`,`title`,`description_extra`,`user_boplakatalog_id_o_product`,`ordernumber`,`uid_product`,`article_type_uid`,`images`,`sys_language_uid`,`l18n_parent`,`user_boplakatalog_downloadfiles`) 
VALUES 
($catPid,$tstamp,$tstamp,".intval($crUser).",'$newname','$newsubtitle',".intval($id_o_product).",'$newartNr',$newUid,1,'$prodFileName',".intval($langId).",".intval($l18Parent).",'$downloadFileName')"; 


$sql = "INSERT INTO tx_commerce_article_prices 
(`pid`,`tstamp`,`crdate`,`cruser_id`,`uid_article`) VALUES 
($catPid,$tstamp,$tstamp,".intval($crUser).",$newArtUid)";

4.) connect products with groups

$sql = "INSERT INTO tx_commerce_products_categories_mm 
(uid_local,uid_foreign,sorting) VALUES 
(".$newUid.",".$myrow2['uid'].",".$myrow['O_SEQUENCE'].")";
$sql = "UPDATE tx_commerce_products set ";
$sql .= "categories = '".implode(',',$catArr)."', sorting = 
".intval($newOSeq)." WHERE uid = $newUid";


More information about the TYPO3-project-commerce mailing list