服务报价 | 域名主机 | 网络营销 | 软件工具| [加入收藏]
 热线电话: #
当前位置: 主页 > php教程 > magento教程 >

Magento重载Controller的方法

时间:2016-12-18 04:01来源:未知 作者:最模板 点击:
Magento重载购物车页 Mage_Checkout_CartController::indexAction(). 第一步:建立相应的文件 app/code/local/MyNameSpace/MyModule/etc/config.xml app/code/local/MyNameSpace/MyModule/controllers/Checkout/CartController.php app/etc/
Magento重载购物车页 
Mage_Checkout_CartController::indexAction().  
 
第一步:建立相应的文件 
app/code/local/MyNameSpace/MyModule/etc/config.xml 
app/code/local/MyNameSpace/MyModule/controllers/Checkout/CartController.php 
app/etc/modules/MyNameSpace_All.xml 
第二步:编辑刚才新建的配置文件 etc/config.xml
 
<?xml version="1.0"?>
<config>
    <modules>
        <MyNameSpace_MyModule>
            <version>0.1.0</version>
        </MyNameSpace_MyModule>
    </modules>
    <global>
        <!-- This rewrite rule could be added to the database instead -->
        <rewrite>
            <!-- This is an identifier for your rewrite that should be unique -->
            <!-- THIS IS THE CLASSNAME IN YOUR OWN CONTROLLER -->
            <mynamespace_mymodule_checkout_cart>
                <from><![CDATA[#^/checkout/cart/#]]></from>
                <!-- 
                    - mymodule matches the router frontname below 
                    - checkout_cart matches the path to your controller
                    
                    Considering the router below, "/mymodule/checkout_cart/" will be 
                    "translated" to "/MyNameSpace/MyModule/controllers/Checkout/CartController.php" (?)
                -->
                <to>/mymodule/checkout_cart/</to>
            </mynamespace_mymodule_checkout_cart>
        </rewrite>
    </global>
    <!-- 
    If you want to overload an admin-controller this tag should be <admin> instead,
    or <adminhtml> if youre overloading such stuff (?)
    -->
    <frontend>
        <routers>
            <mynamespace_mymodule>
                <!-- should be set to "admin" when overloading admin stuff (?) -->
                <use>standard</use>
                <args>
                    <module>MyNameSpace_MyModule</module>
                    <!-- This is used when "catching" the rewrite above -->
                    <frontName>mymodule</frontName>
                </args>
            </mynamespace_mymodule>
        </routers>
    </frontend>
</config>
 
(责任编辑:最模板)
顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------
栏目列表
热点内容