我需要覆盖以下控制器
OnItemClickListener
在一个模块中覆盖Magento的原生结帐。按照Inchoo的教程,我在config.xml中做到了这一点:
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String itemChosen = (String) parent.getItemAtPosition(position);
Intent intent = new Intent(FirstActivity.this, SecondActivity.class);
intent.putExtra("groceryItem", itemChosen);
startActivity(intent);
}
}
我的控制器的代码(AddressController的例子)
app/code/core/Mage/Customer/controllers/AccountController.php
app/code/core/Mage/Customer/controllers/AddressController.php
app/code/core/Mage/Sales/controllers/OrderController.php
但它没有用。
关于我失踪的任何线索?
答案 0 :(得分:2)
这是我写的一个扩展示例。它已经过测试,可以覆盖所有控制器。
config.xml中
<?xml version="1.0" ?>
<config>
<modules>
<Rabee3_Stackoverflow>
<version>1.0.0</version>
</Rabee3_Stackoverflow>
</modules>
<frontend>
<routers>
<sales>
<args>
<modules>
<stackoverflow before="Mage_Sales">Rabee3_Stackoverflow</stackoverflow>
</modules>
</args>
</sales>
<customer>
<args>
<modules>
<stackoverflow before="Mage_Customer">Rabee3_Stackoverflow</stackoverflow>
</modules>
</args>
</customer>
</routers>
</frontend>
</config>
要覆盖的控制器,显示所需的核心文件及其扩展方式:
AccountController.php
require_once(Mage::getModuleDir('controllers','Mage_Customer').DS.'AccountController.php');
class Rabee3_Stackoverflow_AccountController extends Mage_Customer_AccountController
{
AddressController.php
require_once(Mage::getModuleDir('controllers','Mage_Customer').DS.'AddressController.php');
class Rabee3_Stackoverflow_AddressController extends Mage_Customer_AddressController
{
OrderController.php
require_once(Mage::getModuleDir('controllers','Mage_Sales').DS.'OrderController.php');
class Rabee3_Stackoverflow_OrderController extends Mage_Sales_OrderController
{
我希望这会有所帮助。