Skip to content

Example Import Array

blindMoe edited this page Jun 26, 2013 · 2 revisions

This is a quick example taken from: http://stackoverflow.com/questions/13837049/import-export-configurable-products-in-magento

<?php
require_once 'app/Mage.php';

Mage::init();

$entities = array(
    // Configurable product.
    array(
        'description'       => 'Some description',
        '_attribute_set'    => 'Default',
        'short_description' => 'Some short description',
        '_product_websites' => 'base',
        'status'            => Mage_Catalog_Model_Product_Status::STATUS_ENABLED,
        'visibility'        => Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH,
        'tax_class_id'      => 0,
        'is_in_stock'       => 1,
        'sku'               => 'some_configurable',
        '_type'             => Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE,
        'name'              => 'Some configurable',
        'price'             => rand(1, 1000),
        'weight'            => rand(1, 1000),

        // Link the first simple product:
        '_super_products_sku'     => 'my_red_blue_simple', 
        '_super_attribute_code'   => 'color',
        '_super_attribute_option' => 'blue'
    ),

    // Now optionally link some more simple products:
    array(
        '_super_products_sku'     => 'my_red_simple_product', 
        '_super_attribute_code'   => 'color',
        '_super_attribute_option' => 'red'
    )
);

// Start the import.
Mage::getModel('api_import/import_api')->importEntities(
    $entities, 
    Mage_ImportExport_Model_Export_Entity_Product::getEntityTypeCode()
);
Clone this wiki locally