Magento – Override a core page block
Using Magento 1.4.1.1.
After reading a seemingly simple tutorial at http://www.exploremagento.com/magento/override-a-magento-core-block-class.php I ran into some problems. To override the catalog modules breadcrumbs you use the following XML:
<config> <global> <blocks> <catalog> <rewrite> <breadcrumbs>Fido_Catalog_Block_Breadcrumbs</breadcrumbs> </rewrite> </catalog> </blocks> </global> </config>
This is fine for the catalog module, but how do you replace the standard breadcrumbs in 1.4.1.1 which are in core/Mage/Page/Block/Html/Breadcrumbs.php? It took me quite a bit of trial and error, but the key here is the declaration of the block in page.xml:
<block type="page/html_breadcrumbs" name="breadcrumbs" as="breadcrumbs"/>
The type is what indicates how to override. Specifically “page” and “html_breadcrumbs”. To properly override the standard breadcrumbs you would use the following XML:
<config> <global> <blocks> <page> <rewrite> <html_breadcrumbs>AIBooks_Page_Block_Html_Breadcrumbs</html_breadcrumbs> </rewrite> </page> </blocks> </global> </config>
The rest of the article should apply just fine. In my package I mirrored the core code with app/code/local/AIBooks/Page/Block/Html/Breadcrumbs.php with your XML going into app/code/local/AIBooks/Page/etc/config.xml.