Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Override Addresscontroller:  innercontent edit form not shown
 
Giulio12
Jr. Member
 
Total Posts:  3
Joined:  2009-10-21
 

Hello!

I have the following problem.
i have overridden the Address Controller with in my config.xml the follwing.

<Strawberries_Custom_customer_address>
            <
from><![CDATA[#^/customer/address/#]]></from>
             
<to>/custom/customer_address/</to>
</
Strawberries_Custom_customer_address>

Everything seems to work fine(override the actions, viewing the index) , but when i go into edit the addres page ( index.php/customer/address/edit/id/1/)
i get the page but without the innercontent. I think it has to do with the xml setting in customer.xml and magento is trying to search an xml node that isn’t there..

<customer_address_form>
        <!-- 
Mage_Customer -->
        <
update handle="customer_account"/>
        <
reference name="content">
            <
block type="customer/address_edit" name="customer_address_edit" template="customer/address/edit.phtml"/>
        </
reference>
    </
customer_address_form>

I have tried to change it in

<strawberries_custom_customer_address_form>
        <!-- 
Mage_Customer -->
        <
update handle="customer_account"/>
        <
reference name="content">
            <
block type="customer/address_edit" name="customer_address_edit" template="customer/address/edit.phtml"/>
        </
reference>
    </
strawberries_custom_customer_address_form>

but that doesn’t seem to work.. Anyone encountered this problem too??

Thnx in advance!

 
Magento Community Magento Community
Magento Community
Magento Community
 
piotrekkaminski
Magento Team
 
Avatar
Total Posts:  73
Joined:  2007-09-01
 

Hello,

Please show us config.xml configuration for the “custom” front name, layout file definition from config file and code of the rewrited controller.

We hope the above information will allow to help us to find the issue in code.

 
Magento Community Magento Community
Magento Community
Magento Community
 
pierre-vdb
Jr. Member
 
Total Posts:  10
Joined:  2009-06-16
 

Same probleme here.. I’m trying to override the Address controller to be able to format database entries (see this post). When overriding, controller actions works fine but nothing is displayed.

The config.xml of the custom module :

<?xml version="1.0"?>

<config>
    <
modules>
      <
Grandformat_Address>
          <
version>0.1.0</version>
      </
Grandformat_Address>
    </
modules>
    
    <global>
      <
rewrite>
          <
grandformat_address>
             <
from><![CDATA[#^/customer/address/#]]></from>
             
<to>/customer_address/address/</to>
          </
grandformat_address>
      </
rewrite>
    </global>
    
    <
frontend>
      <
routers>
          <
grandformat_address>
              <use>
standard</use>
              <
args>
                  <
module>Grandformat_Address</module>
                  <
frontName>customer_address</frontName>
              </
args>
          </
grandformat_address>
      </
routers>
    </
frontend>

</
config>

The custom controller :

<?php

require_once 'Mage/Customer/controllers/AddressController.php';

class 
Grandformat_Address_AddressController extends Mage_Customer_AddressController
{

    
public function formPostAction()
    
{
        
if (!$this->_validateFormKey()) {
            
return $this->_redirect('*/*/');
        
}
        
        
// Save data
        
if ($this->getRequest()->isPost()) {
            $address 
Mage::getModel('customer/address')
                ->
setData($this->getRequest()->getPost())
                ->
setCustomerId(Mage::getSingleton('customer/session')->getCustomerId())
                ->
setIsDefaultBilling($this->getRequest()->getParam('default_billing'false))
                ->
setIsDefaultShipping($this->getRequest()->getParam('default_shipping'false));
            
$addressId $this->getRequest()->getParam('id');
            if (
$addressId{
                $customerAddress 
$this->_getSession()->getCustomer()->getAddressById($addressId);
                if (
$customerAddress->getId() && $customerAddress->getCustomerId() == $this->_getSession()->getCustomerId()) {
                    $address
->setId($addressId);
                
}
                
else {
                    $address
->setId(null);
                
}
            }
            
else {
                $address
->setId(null);
            
}
            
try {
                $accressValidation 
$address->validate();
                if (
true === $accressValidation{
                    $address
->save();
                    
$this->_getSession()->addSuccess($this->__('The address was successfully saved'));
                    
$this->_redirectSuccess(Mage::getUrl('*/*/index', array('_secure'=>true)));
                    return;
                
else {
                    $this
->_getSession()->setAddressFormData($this->getRequest()->getPost());
                    if (
is_array($accressValidation)) {
                        
foreach ($accressValidation as $errorMessage{
                            $this
->_getSession()->addError($errorMessage);
                        
}
                    } 
else {
                        $this
->_getSession()->addError($this->__('Can\'t save address'));
                    }
                }
            }
            catch (Mage_Core_Exception $e) {
                $this->_getSession()->setAddressFormData($this->getRequest()->getPost())
                    ->addException($e, $e->getMessage());
            }
            catch (Exception $e) {
                $this->_getSession()->setAddressFormData($this->getRequest()->getPost())
                    ->addException($e, $this->__('
Can\'t save address'));
            
}
        }
        $this
->_redirectError(Mage::getUrl('*/*/edit', array('id'=>$address->getId())));
    
}

}

The xml of design/frontend/default/grandformat/layout/customer.xml in attachment

File Attachments
customer.xml  (File Size: 11KB - Downloads: 118)
 
Magento Community Magento Community
Magento Community
Magento Community
 
Giulio12
Jr. Member
 
Total Posts:  3
Joined:  2009-10-21
 

These are my settings.

Strawberries_Custom.xml

<?xml version="1.0"?>
<config>
    <
modules>
        <
Strawberries_Custom>
            <
active>true</active>
            <
codePool>local</codePool>
        </
Strawberries_Custom>
    </
modules>
</
config>

config.xml

<?xml version="1.0"?>
<config>
    <
modules>
        <
Strawberries_Custom>
            <
version>0.1.0</version>
        </
Strawberries_Custom>
    </
modules>
    <
adminhtml>
        <
acl>
            <
resources>
                <
all>
                    <
title>Allow Everything</title>
                </
all>
                <
admin>
                    <
children>
                        <
Strawberries_Custom>
                            <
title>Strawberries</title>
                            <
sort_order>10</sort_order>
                        </
Strawberries_Custom>
                        <
system>
                            <
children>
                                <
config>
                                    <
children>
                                        <
custom>
                                            <
title>SBEOS III</title>
                                        </
custom>
                                    </
children>
                                </
config>
                            </
children>
                        </
system>
                    </
children>
                </
admin>
            </
resources>
        </
acl>
    </
adminhtml>    
    <
frontend>
        <
routers>
            <
custom>
                <use>
standard</use>
                <
args>
                    <
module>Strawberries_Custom</module>
                    <
frontName>custom</frontName>
                </
args>
            </
custom>
        </
routers>
        <
layout>
            <
updates>
                <
custom>
                    <
file>custom.xml</file>
                </
custom>
            </
updates>
        </
layout>
    </
frontend>
    <global>
        <
blocks>
            <
custom>
                <class>
Strawberries_Custom_Block</class>
            </
custom>
            <
custom>
                <
rewrite>
                    <
eos_links>Strawberries_Custom_Block_EosSoap</eos_links>
                </
rewrite>
            </
custom>
            <
custom>
                <
rewrite>
                    <
eos_footernav>Strawberries_Custom_Block_EosSoap</eos_footernav>
                </
rewrite>
            </
custom>
        </
blocks>
        <
helpers>
            <
custom>
                <class>
Strawberries_Custom_Helper</class>
            </
custom>
        </
helpers>  
        <
rewrite>
            <!-- 
This is an identifier for your rewrite that should be unique -->
            <!-- 
THIS IS THE CLASSNAME IN YOUR OWN CONTROLLER -->
            <
Strawberries_Custom_checkout_cart>
               <
from><![CDATA[#^/checkout/cart/#]]></from>
               
<to>/custom/checkout_cart/</to>
            </
Strawberries_Custom_checkout_cart>
            
            <
Strawberries_Custom_checkout_onepage>
                <
from><![CDATA[#^/checkout/onepage/#]]></from>
               
<to>/custom/checkout_onepage/</to>
            </
Strawberries_Custom_checkout_onepage>
            
            <
Strawberries_Custom_customer_account>
                <
from><![CDATA[#^/customer/account/#]]></from>
                
<to>/custom/customer_account/</to>
            </
Strawberries_Custom_customer_account>
            
            <
Strawberries_Custom_customer_address>
                <
from><![CDATA[#^/customer/address/#]]></from>
               
<to>/custom/customer_address/</to>
            </
Strawberries_Custom_customer_address>
            
        </
rewrite>      
    </global>
</
config>

controller

class Strawberries_Custom_Customer_AddressController extends Mage_Customer_AddressController
{
    
    
    
public function indexAction()
    
{
        parent
::indexAction();
    
}
    
    
public function editAction(){
        
        parent
::editAction();
        
    
}
    
}
 
Magento Community Magento Community
Magento Community
Magento Community
 
piotrekkaminski
Magento Team
 
Avatar
Total Posts:  73
Joined:  2007-09-01
 

Hello,

You need to add method to rewrited controller:

public function getFullActionName($delimiter)
{
return ‘customer’.$delimiter.
$this->getRequest()->getControllerName().$delimiter.
$this->getRequest()->getActionName();
}

This should fix the problems with layout, because full action name is used as handle name for layout.

Thank you

 
Magento Community Magento Community
Magento Community
Magento Community
 
Giulio12
Jr. Member
 
Total Posts:  3
Joined:  2009-10-21
 

I did your adjustment, but still getting an empty innercontent..

 
Magento Community Magento Community
Magento Community
Magento Community
 
LindyKyaw
Sr. Member
 
Avatar
Total Posts:  138
Joined:  2008-01-02
Los Angeles
 

If you would like to use the same full_action_name as the core, you can use the following approach to overwrite the controller class.

<frontend>
        <
routers>
            <
customer>
                <
args>
                    <
modules>
                        <
strawberries_custom before="Mage_Customer">Strawberries_Custom_Customer</strawberries_custom>
                    </
modules>
                </
args>
            </
customer>
        </
routers>
    </
frontend>

Then Magento Core will try to look into your module controller class before looking at into Mage_Customer.

 
Magento Community Magento Community
Magento Community
Magento Community
 
pierre-vdb
Jr. Member
 
Total Posts:  10
Joined:  2009-06-16
 

If you would like to use the same full_action_name as the core, you can use the following approach to overwrite the controller class.

Thanks I think it’s actually the best approach.

I ended with a module config.xml as follow :

<?xml version="1.0"?>

<config>
    <
frontend>
        <
routers>
            <
customer>
                <use>
standard</use>
                <
args>
                    <
modules>
                        <
grandformat_customer before="Mage_Customer">Grandformat_Customer</grandformat_customer>
                    </
modules>
                </
args>
            </
customer>
        </
routers>
    </
frontend>
</
config>

and a module tree as attached

 
Magento Community Magento Community
Magento Community
Magento Community
 
PavelPolyakov
Sr. Member
 
Total Posts:  98
Joined:  2009-08-17
 

Up,

It there another problem solutions, If I don’t want to overvrite the full module.

Please, look at this theme.
http://www.magentocommerce.com/boards/viewthread/177340/

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top