After removing category attributes I get these errors in the log file when I reindex "Category Flat Data":

ERR (3): Notice: Undefined offset: 149 in [...]\app\code\core\Mage\Catalog\Model\Resource\Category\Flat.php on line 799

ERR (3): Notice: Undefined offset: 150 in [...]\app\code\core\Mage\Catalog\Model\Resource\Category\Flat.php on line 799

Options "Use Flat Catalog Category" and "Use Flat Catalog Product" under System->Config->Catalog are disabled. It seems that category attributes were removed correctly (after that operation all works without any problems), I did it this way in the setup file:

$setup = $this;
$setup->removeAttribute('catalog_category', 'my_cat_thumbnail1');
$setup->removeAttribute('catalog_category', 'my_cat_thumbnail2');

And the setup file was configured this way in the module's config.xml:


I investigated the Flat.php file and the line 799 (marked with a comment in the snippet below) is inside this method:

 * Return attribute values for given entities and store
 * @param array $entityIds
 * @param integer $store_id
 * @return array
protected function _getAttributeValues($entityIds, $store_id)
    if (!is_array($entityIds)) {
        $entityIds = array($entityIds);
    $values = array();

    foreach ($entityIds as $entityId) {
        $values[$entityId] = array();
    $attributes = $this->_getAttributes();
    $attributesType = array(
    foreach ($attributesType as $type) {
        foreach ($this->_getAttributeTypeValues($type, $entityIds, $store_id) as $row) {
            $values[$row['entity_id']][$attributes[$row['attribute_id']]['attribute_code']] = $row['value']; //THIS IS THE LINE
    return $values;

On line 799, this part of the code: $row['attribute_id'] returns 149. The same number is in the error message:

Undefined offset: 149...

Number 149 is the value of the attribute_id column in the eav_attribute table in database. So 149 is the ID of the attribute that was already removed. The row with this ID in the eav_attribute table doesn't exist anymore (since this attribute was removed). But somehow Magento still tries to get the data of this attribute for some categories.

So this $row['attribute_id'] returns 149. And when Magento tries to get element 149 from this array: $attributes[$row['attribute_id']] it throws error because there is no attribute with ID 149 in $attributes array.

It looks like attributes were removed from the eav_attribute table, but Magento still stores the data of the removed attributes for some categories. If a category had any data in those removed attributes, that data is still stored in the database.

  1. But shouldn't it be removed since I removed the attributes?
  2. Or did I remove the attributes incorrectly?
  • take a look at this: magento.stackexchange.com/a/26445/146. Maybe you are missing some constraints on the category EAV tables. Normally when an attribute is deleted, the values for that attribute should be deleted also.
    – Marius
    Commented Jul 15, 2014 at 13:13

3 Answers 3


The eav_attribute's values are still in the entities value tables (catalog_category_entity_text, catalog_category_entity_int, etc.) and therefor the flat indexer is giving you issues.

Easiest way to solve this is to install this N98 Magerun addon https://github.com/magento-hackathon/EAVCleaner and run its eav:clean:attributes-and-values-without-parent command.

Afaik there are no foreign key constraints from the attribute_id column on the value tables to the eav_attribute table, so it doesn't automatically delete them. I'm not sure why..

  • EAVCleaner does not support table prefix (yet)
    – snh_nl
    Commented Jul 16, 2015 at 9:45

Its seems like you didn't remove your attribute correctly. I just tried the same attributes that you created in my local server. And also I have removed the attributes safely. To remove attribute use the below code,

$setup = new Mage_Eav_Model_Entity_Setup('core_setup');

$setup->removeAttribute('catalog_category', 'my_cat_thumbnail1');
$setup->removeAttribute('catalog_category', 'my_cat_thumbnail2');

put this code in some where in file, make sure that file ll execute . or access your store from external file like this,

require_once 'app/Mage.php';
$websiteId = Mage::app()->getWebsite()->getId();

$setup = new Mage_Eav_Model_Entity_Setup('core_setup');

$setup->removeAttribute('catalog_category', 'my_cat_thumbnail1');
$setup->removeAttribute('catalog_category', 'my_cat_thumbnail2');

echo 'success';

And if you want completely remove the attribute (I am saying history), then delete the setup entry in core_resource table, and delete also module files that you were put in local or community directory and xml file in etc/modules..

  • I'm not sure I understand you correctly. This is exactly what I did, I used this code to remove attributes: $setup->removeAttribute('catalog_category', 'my_cat_thumbnail1'); where $installer is an instance of Mage_Eav_Model_Entity_Setup. I edited my question and added the code snippet.
    – d3tr5845
    Commented Jul 7, 2014 at 14:00

Suppose the ID in error is 187. And you are sure that it needs to be/was removed.

Step 1. Open the following tables and check for it. It should not exist.

  • catalog_eav_attribute and check for existance of attribute_id = 187
  • eav_attribute and check for existance of attribute_id = 187

Step 2. Then open the following (value) tables catalog_category_entity_datetime, catalog_category_entity_varchar, catalog_category_entity_int, catalog_category_entity_decimal and catalog_category_entity_text

  • Again search for rows with attribute_id = 187 and delete

Step 3. Answer needs an update to complete.

Because after re-indexing the catalog_category_entity_int values keep being re-created. It is I think coming from the table catalog_category_entity where the correct entity_id's also need to be removed. But of this I am not sure.

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.