如何

2013-11-28 50 views
2

我有一个需要重写的优惠券代码的功能如何

<frontend> 
    <routers> 
     <customcoupons> 
      <use>standard</use> 
      <args> 
       <module>Mycompany_Customcoupons</module> 
       <frontName>customcoupons</frontName> 
      </args> 
     </customcoupons> 
     <checkout><!-- Override code starts--> 
             <args> 
                 <modules> 
              <Mycompany_Customcoupons before="Mage_Checkout">Mycompany_Customcoupons</Mycompany_Customcoupons> 
          </modules> 
             </args> 
        </checkout><!-- Override code ends--> 
    </routers> 
    <layout> 
     <updates> 
      <customcoupons> 
       <file>customcoupons.xml</file> 
      </customcoupons> 
     </updates> 
    </layout> 
</frontend> 

我的工作很好,如果我没加超越代码自定义模块管理页面模块覆盖车控制器息行动,我们的自定义模块的Magento但如果我添加<checkout>块它显示404页。可能是什么问题呢?如何在此添加覆盖块?

回答

6

请写在你的config.xml

<global> 
    <rewrite> 
     <mycompany_customcoupons> 
       <from><![CDATA[#^/checkout/cart/#]]></from> 
       <to>/customcoupons/cart/</to> 
     </mycompany_customcoupons> 
    </rewrite> 

</global> 

立即创建文件:应用程序/代码/本地/ MyCompany的/ Customcoupons/CartController.php

在CartController。 PHP,写波纹管代码。

<?PHP 

require_once 'Mage/Checkout/controllers/CartController.php'; 

class Mycompany_Customcoupons_CartController extends Mage_Checkout_CartController 
{ 

    public function couponPostAction() 
    { 
     // Start You code here. 
    } 
} 

?> 
+2

谢谢:)因为我的模块'frontName'是'customcoupons' !!因此我的模块'frontName'因为改变'/mycompany_customcoupons/cart/'到'/customcoupons/cart/' –

+0

是的,这是我在那里的错误。不客气。 –