-
- uniacid

-
Total Posts: 8
Joined: 2008-12-12
|
If anyone hasn’t had success yes importing their products manually, I created a script that helped me with the nutrional product database I had to import. The code should be pretty obvious but if you have any questions let me know.
<?php include 'config.php'; include 'opendb.php';
$newDbFields = array ( "store"=>array("default"=>"default", "type"=>"string"), "websites"=>array("default"=>"base", "type"=>"string"), "attribute_set"=>array("default"=>"Default", "type"=>"string"), "type"=>array("default"=>"simple", "type"=>"string"), "sku"=>array("type"=>"number"), "category_ids"=>array("type"=>"string"), "has_options"=>array("default"=>"0","type"=>"string"), "name"=>array("type"=>"string"), //"url_key"=>"dynamic", //"url_path"=>"dynamic", "image"=>array("default"=>"image","type"=>"string"), "small_image"=>array("default"=>"image","type"=>"string"), "thumbnail"=>array("default"=>"image","type"=>"string"), "price"=>array("type"=>"number"), "special_price"=>array("type"=>"number"), "weight"=>array("type"=>"number"), "description"=>array("type"=>"string"), "short_description"=>array("type"=>"string"), "directions"=>array("type"=>"string"), "indications"=>array("type"=>"string"), "ingredients"=>array("type"=>"string"), "warnings"=>array("type"=>"string"), "drug_interactions"=>array("type"=>"string"), "manufacturer"=>array("type"=>"string"), "special_from_date"=>array("default"=>"2008-12-01 00:00:00","type"=>"string"), "status"=>array("default"=>"Enabled", "type"=>"string"), "tax_class_id"=>array("default"=>"None", "type"=>"string"), "visibility"=>array("default"=>"Catalog, Search", "type"=>"string"), "qty"=>array("default"=>"100.0000", "type"=>"string"), "min_qty"=>array("default"=>"0.0000", "type"=>"string"), "use_config_min_qty"=>array("default"=>"1", "type"=>"string"), "is_qty_decimal"=>array("default"=>"0", "type"=>"string"), "backorders"=>array("default"=>"0", "type"=>"string"), "use_config_backorders"=>array("default"=>"1", "type"=>"string"), "min_sale_qty"=>array("default"=>"1.0000", "type"=>"string"), "use_config_min_sale_qty"=>array("default"=>"1", "type"=>"string"), "max_sale_qty"=>array("default"=>"0.0000", "type"=>"string"), "use_config_max_sale_qty"=>array("default"=>"1", "type"=>"string"), "is_in_stock"=>array("default"=>"1", "type"=>"string"), //"low_stock_date"=>array("default"=>"None", "type"=>"string"), //"notify_stock_qty"=>array("default"=>"None", "type"=>"string"), "use_config_notify_stock_qty"=>array("default"=>"1", "type"=>"string"), "manage_stock"=>array("default"=>"0", "type"=>"string"), "use_config_manage_stock"=>array("default"=>"1", "type"=>"string"), "stock_status_changed_automatically"=>array("default"=>"0", "type"=>"string") );
$oldDbFields = array ( "Product.UPC"=>"sku", "ProductInfo.PRIMARY_CATEGORY"=>"category_ids", "Product.ItemName"=>"name", "ProductInfo.RETAIL_PRICE"=>"price", "ProductInfo.SELLING_PRICE"=>"special_price", "Product.ProductWeight"=>"weight", "Product.ProductDetails" => "description", "Product.Description" => "short_description", "Product.Directions" => "directions", "Product.Indications" => "indications", "Product.Ingredients" => "ingredients", "Product.Warnings" => "warnings", "Product.DrugInteractions" => "drug_interactions", "Product.Manufacturer"=>"manufacturer", );
$primaryCatArr = array();
print("<pre>");
$primaryCatArr = array( 0 => "", 1 => "", 2 => "", 3 => "", 4 => "Amino Acids", 5 => "Anabolic Precursors", 6 => "Bars", 7 => "Clothes", 8 => "Creatine", 9 => "Dietary Fats / Oils", 10 => "Drinks", 11 => "Fitness Accessories", 12 => "Herbs", 13 => "Joint Care", 14 => "Low Carb Products", 15 => "Meal Replacements", 16 => "Nitric Oxide", 17 => "Protein", 18 => "Snacks / Foods", 19 => "Sport Performance", 20 => "Tanning Products", 21 => "Vitamins / Minerals", 22 => "Weight Gain", 23 => "Weight Loss / Energy" );
$fp = fopen('file.csv', 'w'); $recordCount = 0; //build field list for sql $oldDbFieldArr = array(); foreach( $oldDbFields as $field=>$asField ) array_push($oldDbFieldArr, $field . " " . $asField);
$query = "SELECT ".implode(',', $oldDbFieldArr)." FROM Product INNER JOIN tblWebProducts as ProductInfo ON (ProductInfo.STOCK_CODE = Product.StockCode)";
$result = mysql_query($query);
|