Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email

Magento Forum

Setting Data to NULL
Jr. Member
Total Posts:  14
Joined:  2008-08-08

Hi Community,

How do I set a attribute value to NULL (DATABASE NULL)?
I am a bit embarrassed but i did not find a way to do this.

My Model extends Mage_Core_Model_Abstract

The usual

does not work with

The issue afaik is that
Line 406 is commented out
but there must be another way.

protected function _prepareDataForSave(Mage_Core_Model_Abstract $object)
= array();
$fields $this->_getWriteAdapter()->describeTable($this->getMainTable());
        foreach (
array_keys($fields) as $field{
            if (
$fieldValue instanceof Zend_Db_Expr{
elseif (!is_null($fieldValue)) {
else {
//                $data[$field] = $fieldValue;
return $data;

Do i have to use a Zend_Db_Expr set it to NULL ?

Help is ... as always ... very much appreciated


Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top