Layout Handle for Product Grid and List View in Magento

layoutproduct-liststock

I have created my own small extension to handle what is displayed for the in-stock and out-of-stock messages.

In the layout file MyModule_Availability.xml I have

<PRODUCT_TYPE_simple>
    <reference name="product.info.simple">
        <action method="setTemplate">
            <template>MyModule/Availability/catalog/product/view/type/default.phtml</template>
        </action>
    </reference>
</PRODUCT_TYPE_simple>

which works like a charm.

But that is only the individual product. I want to display the same changes in list and grid mode as well.

So I am trying to find what I need to put around

    <action method="setTemplate">
        <template>MyModule/Availability/catalog/product/list.phtml</template>
    </action>

For my list.phtml to be used.

When I display handleinformation in the shop I get the following:

frontend/default/ma_erida/template/catalog/product/list.phtml

Mage_Catalog_Block_Product_List

I hope you can help.

Best Answer

Using the handles: catalog_category_default, catalog_category_layered and catalogsearch_result_index you should be able to change the template of the products list.

For the two category layout handles you would need the following snippet.

<catalog_category_default>
    <reference name="product_list">
        <action method="setTemplate">
            <template>MyModule/Availability/catalog/product/list.phtml</template>
        </action>
    </reference>
</catalog_category_default>
<catalog_category_layered>
    <reference name="product_list">
        <action method="setTemplate">
            <template>MyModule/Availability/catalog/product/list.phtml</template>
        </action>
    </reference>
</catalog_category_layered>

But for the search results page you would need to make a slight change as the block is not called product_list but search_result_list:

<catalogsearch_result_index>
    <reference name="search_result_list">
        <action method="setTemplate">
            <template>MyModule/Availability/catalog/product/list.phtml</template>
        </action>
    </reference>
</catalogsearch_result_index>