Can't get module to fire controller

By : Amber
Source: Stackoverflow.com
Question!

I can't get my controller to fire. So I must be doing something wrong, but I can't figure it out and I am hoping someone can steer me in the right direction. Below is my config.xml file.

<?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>

Here is my controller:

<?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');
    }
}

Thank you for your help in advance.

By : Amber


Answers
I think you need to change your config to be

<frontend>
    <routers>
        <giftregistry>
            <args>
                <modules>
                    <Unleaded_GiftRegistry before="Enterprise_GiftRegistry">Unleaded_GiftRegistry</Unleaded_GiftRegistry>
                </modules>
            </args>
        </giftregistry>
    </routers>
 </frontend>

Notice that I have replaced "giftregistry" in the grandchild node with "Unleaded_GiftRegistry".

Also, your Mage::log() instruction will never be hit since it is outside of an Action.

Try using ConfigViewer or CommerceBug from @AlanStorm to check whether your rewrites are being parsed correctly by Magento's Config.

HTH,
JD



This video can help you solving your question :)
By: admin