0

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.

https://i.stack.imgur.com/rN7V3.jpg

2 Answers 2

1

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.

1

For importing products using a CSV file I would recommend to use Magmi:

http://sourceforge.net/projects/magmi/

It's a great and free solution for importing almost any product related data into Magento. It will definitely save you the time of writing your own solution.

Licensed under the MIT license.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.