dimajanzen / AvS_FastSimpleImport

Wrapper for Magento ImportExport functionality, which imports products and customers from arrays

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

FastSimpleImport - Array Adapter for Magento ImportExport

Import products and customers into Magento, using the new fast ImportExport core module.

This module allows to import from arrays and thus using any import source, while the Magento module only imports from files. ImportExport exists since Magento 1.5 CE / 1.10 EE, image import since 1.6 CE / 1.11 EE. Thus, this module needs at least one of those versions.

Basic Usage

Call it like this:

// Import product:
$data = array(
    array(
        'sku' => '1234567',
        '_type' => 'simple',
        '_attribute_set' => 'Default',
        '_product_websites' => 'base',
        'name' => 'Default',
        'price' => 0.99,
        'description' => 'Default',
        'short_description' => 'Default',
        'weight' => 0,
        'status' => 1,
        'visibility' => 4,
        'tax_class_id' => 2,
        'qty' => 76,
    ),
    // add more products here
);
Mage::getSingleton('fastsimpleimport/import')
    ->processProductImport($data); 

// Import customer:
Mage::getSingleton('fastsimpleimport/import')
    ->processCustomerImport($data);

You can see the test file for more examples.

See specifications about the expected format.

Features

  • Import products and customers from php arrays (see above)
  • Bugfix for ImportExport: default values were set on updates when the attribute was not given (only when a default value was present, i.e. with visibility)
  • Choose Import Behavior: "Replace" (default), "Append" or "Delete" like this:
Mage::getSingleton('fastsimpleimport/import')
    ->setBehavior(Mage_ImportExport_Model_Import::BEHAVIOR_DELETE)
    ->processProductImport($data);
  • Activate Indexing of imported (or deleted) products only (Partial Indexing)
Mage::getSingleton('fastsimpleimport/import')
    ->setPartialIndexing(true)
    ->processProductImport($data);
  • Improved assigning of categories. In default, you can assign the category by giving the breadcrumb path below the root category, i.e. "Electronics/Cameras/Digital Cameras". Now, you can add the root category for uniqueness ("Root Catalog/Electronics/Cameras/Digital Cameras") or just the category id ("26").
  • Download images with http. Just enter the URL in the field _media_image, while image, small_image und thumbnail get the filename only.
  • NEW: Stop creating image duplicates (_1, _2, _3, etc.)
Mage::getSingleton('fastsimpleimport/import')
    ->setAllowRenameFiles(false);
  • Create options for predefined attributes automatically.
Mage::getSingleton('fastsimpleimport/import')
    ->setDropdownAttributes('color')
    ->processProductImport($data);

or

Mage::getSingleton('fastsimpleimport/import')
    ->setDropdownAttributes(array('manufacturer', 'color'))
    ->processProductImport($data);
  • Continue import after error in parts of import data:
Mage::getSingleton('fastsimpleimport/import')
    ->setContinueAfterErrors(true)
    ->processProductImport($data);
  • NEW: Import categories:
$data = array();
$data[] = array(
    '_root' => 'Default Category',
    '_category' => 'Test2',
    'name' => 'Test2',
    'description' => 'Test2',
    'is_active' => 'yes',
    'include_in_menu' => 'yes',
    'meta_description' => 'Meta Test',
    'available_sort_by' => 'position',
    'default_sort_by' => 'position',
);
$data[] = array(
    '_root' => 'Default Category',
    '_category' => 'Test2/Test3',
    'name' => 'TestTest',
    'description' => 'Test3',
    'is_active' => 'yes',
    'include_in_menu' => 'yes',
    'meta_description' => 'Meta Test',
    'available_sort_by' => 'position',
    'default_sort_by' => 'position',
);

/** @var $import AvS_FastSimpleImport_Model_Import */
$import = Mage::getModel('fastsimpleimport/import');
try {
    $import->processCategoryImport($data);
} catch (Exception $e) {
    print_r($import->getErrorMessages());
}

About

Wrapper for Magento ImportExport functionality, which imports products and customers from arrays


Languages

Language:PHP 100.0%