3

I created a static product attribute with corresponding source model:


/* @var $installer Mage_Catalog_Model_Resource_Setup */
$installer = $this;
$installer->startSetup();
$installer->getConnection()->addColumn(
    $installer->getTable('catalog/product'), 'my_attribute', array(
        'type'    => Varien_Db_Ddl_Table::TYPE_INTEGER,
        'comment' => 'Delivery Point ID'
    )
);
$installer->getConnection()->addIndex(
    $installer->getTable('catalog/product'),
    $installer->getConnection()->getIndexName(
        $installer->getTable('catalog/product'), array('my_attribute',)
    ),
    array('my_attribute')
);

$installer->endSetup();

$installer->addAttribute(
    Mage_Catalog_Model_Product::ENTITY,
    'my_attribute',
    array(
        'group'                   => 'General',
        'sort_order'              => 20,
        'type'                    => 'static',
        'label'                   => 'My Attribute',
        'input'                   => 'select',
        'source'                  => 'my_module/entity_attribute_source_mysource',
        'global'                  => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
        'visible'                 => true,
        'required'                => true,
        'user_defined'            => false,
        'visible_on_front'        => true,
        'unique'                  => false,
        'is_configurable'         => false,
        'used_in_product_listing' => true,
    )
);


From the admin panel everything works fine, but when I use the csv import, no data is written to the column my_attribute in catalog_product_entity table.

Here is the csv:


sku,_store,_type,_attribute_set,name,description,short_description,my_attribute,status,visibility,weight,price,tax_class_id,_product_websites
test,,simple,Default,Test,Test,Test,"My Value",1,4,0,0,0,base

The source model gives the correct values, otherwise the validation of the csv file would fail.

Is this case supported by the Mage_ImportExport module at all?

1 Answer 1

1

It seems you are right, it is impossible to import static attributes: https://github.com/LokeyCoding/magento-mirror/blob/magento-1.9/app/code/core/Mage/ImportExport/Model/Import/Entity/Product.php#L1314-L1321

The question here is more: Why do you want to create a static attribute? Performance shouldn't be to big of a problem, even querying the EAV tables shouldn't be too slow if you aren't doing anything special.

Performance on the frontend usually isn't a problem, since the column gets copied to the _flat tables.

For your own sanity: Go with a non-static attribute.

1
  • This is really the only write access on table 'catalog_product_entity'. So it is not possible to import static attributes via Mage_ImportExport.
    – Thorsten
    May 22, 2014 at 8:58

Your Answer

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

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