Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm looking to add indexes the table to it to make lookups faster. If you manually add an index in MySQL, it will disappear at the next Magento "reindexing" event.

share|improve this question

This happens here \Mage_Catalog_Model_Resource_Product_Flat_Indexer::prepareFlatTable

The table is built with magentos DDL $table = $adapter->newTable($tableName);

$table->setComment("Catalog Product Flat (Store {$storeId})");

And if you are looking for a nice event, I think catalog_product_flat_rebuild should do

public function updateEventAttributes($storeId = null)
    Mage::dispatchEvent('catalog_product_flat_rebuild', array(
        'store_id' => $storeId,
        'table'    => $this->getFlatTableName($storeId)

This method is called in

public function rebuild($store = null)
    // ...
    // ...

But I only read code, so please test, whether this works as expected :-)

share|improve this answer
What do you think about copying this file to the local folder and editing public function getFlatIndexes and adding my own $this->_indexes['IDX_MYCOLUMN'] = array('type'=>'unique','fields'=>array('my_column'))? – Buttle Butkus Mar 21 '14 at 6:14
I prefer always events, because with the next magento update (and if something was changed) you burn in hell with this approach :-) – Fabian Blechschmidt Mar 21 '14 at 9:33

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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