1

Does anyone know why meta_title attribute is missing both for product and category flat tables?

I can see meta_description and meta_keyword fields in the flat tables but no meta_title. So I am forced to use eav model, which is fine. But I was wondering why is this so. Also does anyone has a "fix" for this in order to add meta_title to the flat tables?

2
  • Open attribute in admin, set "Use in product listing" as Yes, and then try re-indexing.
    – Prateek
    Feb 17 '16 at 11:31
  • @Prateek please post this as an answer, I will give it a try and if this works I will accept your answer since is the most simple thing to do IMHO
    – lloiacono
    Feb 17 '16 at 11:39
1

Open 'meta_title' attribute in admin, set "Use in product listing" as Yes, and then try re-indexing. AFAIK, Only attributes selected to be "Used in Product Listing" get included in flat tables.

2
  • This method will only work for product_flat but not for category_flat tables, do you know if is possible to do the same for categories? Maybe with a sql update to set this value for the category attribute?
    – lloiacono
    Feb 17 '16 at 11:46
  • For categories, it should be pulled automatically. Take a look at class Mage_Catalog_Model_Resource_Category_Flat. It takes all attributes while creating flat tables for categories in a store. I have a stock installation and I can see 'meta_title' in the columns.
    – Prateek
    Feb 17 '16 at 12:07
1

You can do this by adding meta_title attribute at frontend/product/collection/attributes node at config.xml

<frontend>
     <product>
         <collection>
             <attributes>
                 <meta_title/>
             </attributes>
         </collection>
     </product>
</frontend>

Explanation:

Let explain:

First look at class Mage_Catalog_Model_Resource_Product_Flat_Indexer .

and a function name getAttributeCodes() which responsible for columns creation at catalog product flat.

Magento is first take the attributse from global/catalog/product/flat/attribute_nodes using

Mage::getConfig() ->getNode(self::XML_NODE_ATTRIBUTE_NODES) ->children();

from config.xml at app/code/core/Mage_Catalog/etc/

 <flat>
                    <max_index_count>64</max_index_count>
                    <attribute_nodes>
                        <product_collection>frontend/product/collection/attributes</product_collection>
                    </attribute_nodes>
                    <add_filterable_attributes>0</add_filterable_attributes>
                    <add_child_data>0</add_child_data>
                    <flag>
                        <model>catalog/product_flat_flag</model>
                    </flag>
                </flat>

Which internally call config node: frontend/product/collection/attributes.

If we define an attribute here then this attribute will automatically added as columns in flat table.

 <frontend>
        <product>
            <collection>
                <attributes>
                      <attribute_Code/>
                </attributes>
            </collection>
        </product>
    </frontend>

Then need to product flat index form index management.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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