我无法让我的控制器开火。所以我一定做错了什么,但我无法弄清楚,我希望有人能引导我朝着正确的方向前进。下面是我的config.xml文件。
<?xml version="1.0"?>
<config>
<modules>
<Unleaded_GiftRegistry>
<version>0.1.0</version>
</Unleaded_GiftRegistry>
</modules>
<frontend>
<routers>
<giftregistry>
<args>
<modules>
<giftregistry before="Enterprise_GiftRegistry">Unleaded_GiftRegistry</giftregistry>
</modules>
</args>
</giftregistry>
</routers>
</frontend>
</config>
这是我的控制器:
<?php
include_once("Enterpise/GiftRegistry/controllers/IndexController.php");
class Unleaded_GiftRegistry_IndexController extends Enterprise_GiftRegistry_IndexController
{
Mage::log("Some useful debugging information");
/**
* Add product items to customer active gift registry action
*/
public function giftregistryAction()
{
if ($item = $this->getRequest()->getParam('product')) {
try {
$entity = Mage::getModel('enterprise_giftregistry/entity')
->load($this->getRequest()->getParam('entity'));
if ($entity && $entity->getId()) {
$entity->addItem((int)$item);
$this->_getSession()->addSuccess(
Mage::helper('enterprise_giftregistry')->__('The item have been added to gift registry.')
);
}
} catch (Mage_Core_Exception $e) {
if ($e->getCode() == Enterprise_GiftRegistry_Model_Entity::EXCEPTION_CODE_HAS_REQUIRED_OPTIONS) {
$product = Mage::getModel('catalog/product')->load((int)$item);
$query['options'] = Enterprise_GiftRegistry_Block_Product_View::FLAG;
$query['entity'] = $this->getRequest()->getParam('entity');
$this->_redirectUrl($product->getUrlModel()->getUrl($product, array('_query' => $query)));
return;
}
$this->_getSession()->addError($e->getMessage());
$this->_redirect('giftregistry');
return;
} catch (Exception $e) {
$this->_getSession()->addError($this->__('Failed to add item to gift registry.'));
}
}
$this->_redirect('giftregistry');
}
}
提前感谢您的帮助。
答案 0 :(得分:0)
我认为您需要将配置更改为
<frontend>
<routers>
<giftregistry>
<args>
<modules>
<Unleaded_GiftRegistry before="Enterprise_GiftRegistry">Unleaded_GiftRegistry</Unleaded_GiftRegistry>
</modules>
</args>
</giftregistry>
</routers>
</frontend>
请注意,我已使用“Unleaded_GiftRegistry”替换孙子节点中的“giftregistry”。
此外,您的Mage::log()
指令永远不会被命中,因为它不属于Action。
尝试使用@AlanStorm中的ConfigViewer或CommerceBug来检查Magento的Config是否正确解析了您的重写。
HTH,
JD