5

I have a Magento 1.8 CE and I figured out that when using "Product Flat Catalog", the attribute "image" is not collected. How can i add that attribute to "Product Flat Catalog" It is not possible to set "Use for Listing" from Manage Attributes.

Any other way to do that?

3

the solution that I found is most clean and uses Magento's XML-style abstractions to add the image column to the catalog_product_flat_1 table: try this code:- In config.xml:

<config>
    <frontend>
        <product>
            <collection>
                <attributes>
                    <image />
               </attributes>
            </collection>
        </product>
    </frontend>
</config>

Then reindex your flat catalog tables (Admin > Index Management > Select All + Reindex) and clear all Magento caches.

  • Shall I add that code in app/etc/config.xml? – user2478262 Jul 2 '15 at 11:45
  • yes add the code frinds – Ashvin Monpara Jul 2 '15 at 11:47
4

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

<frontend>
    <product>
        <collection>
            <attributes>
                  <image/>
            </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.