среда, 14 августа 2013 г.

Overriding a Magento Core Controller or a Controller Action

<!– For whole controller –>
<rewrite>
<yournamespace_yourmodule_sales_order >
<from><![CDATA[#^/admin/sales_order/ #]]></from>
<to>/ yourmodule /sales_order/ </to>
</ yournamespace_yourmodule_sales_order >
</rewrite>

<!– For a action in a controller –>
<rewrite>
< yournamespace_yourmodule_sales_order_pdfdocs>
<from><![CDATA[#^/admin/sales_order/pdfdocs#]]></from>
<to>/ yourmodule /sales_order/pdfdocs</to>
</ yournamespace_yourmodule_sales_order_pdfdocs >
</rewrite>


<!--Another Way-->

In your Local/Core/etc/config.xml, define your controller within the router to be overridden.
<config>
    ...
    <frontend> // Use <admin> for backend routers
        <routers>
            <core> // <-- this is the router name
                <args>
                    <modules>
                        <local_core before="Mage_Core">Local_Core</local_core>
                    </modules>
                </args>
            </core>
        </routers>
    </frontend>
    ...
</config>
Magento will now check Local/Core/controllers before Mage/Core/controllers for URL paths starting with core (the router name). Your PHP class above is already correct.
This is only gently hinted at about halfway down this page where it says:
Since Magento 1.3 you can simply add your module to the frontend router. Rewrites are not neccessary any more.

Комментариев нет:

Отправить комментарий