Magento user created attribute for products is not saved...

Posted by Elzo Valugi on Stack Overflow See other posts from Stack Overflow or by Elzo Valugi
Published on 2010-03-10T16:41:41Z Indexed on 2010/03/12 15:37 UTC
Read the original article Hit count: 289

Filed under:

I am fighting an apparently simple thing for about two days now. I hope somebody can help.

I created the myUpdate EAV attribute

class Company_Module_Model_Resource_Eav_Mysql4_Setup extends Mage_Eav_Model_Entity_Setup
{
    public function getDefaultEntities()
    {
        return array(
            'catalog_product' => array(
                'entity_model'      => 'catalog/product',
                'attribute_model'   => 'catalog/resource_eav_attribute',
                'table'             => 'catalog/product',
                'additional_attribute_table' => 'catalog/eav_attribute',
                'entity_attribute_collection' => 'catalog/product_attribute_collection',
                'attributes'        => array(
                    'my_update' => array(
                        'label'             => 'My timestamp',
                        'type'              => 'datetime',
                        'input'             => 'date',
                        'default'           => '',
                        'class'             => 'validate-date',
                        'backend'           => 'eav/entity_attribute_backend_datetime',
                        'frontend'          => '',
                        'table'             => '',
                        'source'            => '',
                        'global'            => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
                        'visible'           => true,
                        'required'          => false,
                        'user_defined'      => true,
                        'searchable'        => false,
                        'filterable'        => false,
                        'comparable'        => false,
                        'visible_on_front'  => false,
                        'visible_in_advanced_search' => false,
                        'unique'            => false,
                        'apply_to'          => 'simple',
                    )
                )
            )
        );
    }
}

The attribute is created OK and on install appears correctly in the list of attributes.

Later I do

// for product 1
$product->setMyUpdate($stringDate); // string this format: yyyy-MM-dd HH:mm:ss
$product->save(); // and saves without issues * in admin module

But later when I do:

$product = Mage::getModel('catalog/product')->load(1);
var_dump($product->getMyUpdate()); // returns null

Somehow the data is not really saved.. or I am not retrieving it correctly. Please advice on how to get the data and where the data is saved in the DB so I can check at if the insert is done correctly.

Thanks.

© Stack Overflow or respective owner

Related posts about magento