Magento – import products from csv

csvimportimportexportPHP

I'm trying to bulk import my product from a .csv. Here is my code so far:

include_once "../app/Mage.php";
include_once "../downloader/Maged/Controller.php";

Mage::init();

// Set the store id
//$app = Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
$app = Mage::app('default');
$row = 0;

$categories = array(
    'Category 1' => 3,
    'Category 2' => 4,
    'Category 3' => 5,
    'Category 4' => 6,  
);

if(($handle = fopen("import.csv", "r")) !== FALSE){
    while(($data = fgetcsv($handle, 1000, ';')) !== FALSE){
        $simpleProduct->setSku($data[2]);
        etc
    }
}

The problem is when I save the product the variable is a random string of numbers. Here's my csv.

http://imgur.com/CCkMKOM

Best Answer

I would suggest that instead of building your own import process that you investigate either the Magento core import/export process or a third party import/export process like FastSimple_Import or HO_Import

The reason I suggest that you do this is it will not only save you time but it should also help you avoid common mistakes that either the core module does not contain or that the third party developers have already found out and solved.

Related Topic