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

Page 1 of 2
magento 1.3.0
 
KeyboardCowboy
Member
 
Total Posts:  65
Joined:  2008-07-01
Berlin, Germany
 

this module doesnt work under magento 1.3.0:

Notice: Array to string conversion in /var/www/magento1.3.0/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php on line 352

on every page request in backend and frontend

 
Magento Community Magento Community
Magento Community
Magento Community
 
NafeX
Member
 
Total Posts:  47
Joined:  2007-12-18
 

the same for me. after disableing the module with <active>false</active> in LKC_ModularRouters.xml, the page loades again.

 
Magento Community Magento Community
Magento Community
Magento Community
 
symmetrics_si
Member
 
Avatar
Total Posts:  36
Joined:  2009-03-06
 

Edit the file /app/code/core/Mage/Core/Controller/Varien/Router/Standart.php

Go to the function “public function getControllerFileName($realModule, $controller)” (line 350)
and add the following code:

if (is_array($realModule)) {
            $realModule 
$realModule[0];
        
}

so that the function looks like:

public function getControllerFileName($realModule$controller)
    
{
        
if (is_array($realModule)) {
            $realModule 
$realModule[0];
        
}
         
        $parts 
explode('_'$realModule);
.....

That fixed the Error!

EDIT: But it don`t fix the problem, because then comes the next error hmmm

 
Magento Community Magento Community
Magento Community
Magento Community
 
symmetrics_bl
Member
 
Avatar
Total Posts:  58
Joined:  2008-01-07
Hannover
 

@ Lee: Thanks for the extension, it is great. Just have one question: When the update/adoption on 1.3. is expected? We need this as soon as possible.

 
Magento Community Magento Community
Magento Community
Magento Community
 
circa1977
Member
 
Total Posts:  65
Joined:  2008-03-01
 

I’m in the same boat. A victim of another extension pulling in the 1.3.0 update, which is not Lee’s fault, but I’m eager to see an update as some crucial components of our site depend upon Modular Routers.

Has anyone found a viable workaround or anything in 1.3.0 that would support custom controllers or overrides similarly?

Thanks,
Mark

 
Magento Community Magento Community
Magento Community
Magento Community
 
NafeX
Member
 
Total Posts:  47
Joined:  2007-12-18
 
circa1977 - 17 April 2009 05:56 AM

I’m in the same boat. A victim of another extension pulling in the 1.3.0 update, which is not Lee’s fault, but I’m eager to see an update as some crucial components of our site depend upon Modular Routers.

Has anyone found a viable workaround or anything in 1.3.0 that would support custom controllers or overrides similarly?

Thanks,
Mark

i need this too…

please help someone

 
Magento Community Magento Community
Magento Community
Magento Community
 
LeeSaferite
Guru
 
Avatar
Total Posts:  322
Joined:  2007-08-31
Lake City, FL
 

Try something like this (Without my module)

/app/code/local/MyCompany/MyModule/etc/config.xml

<config>
   <
frontend>
      <
routers>
         <
customer>
            <
args>
               <
modules>
                  <
MyCompany_MyModule before="Mage_Customer">MyCompany_MyModule<MyCompany_MyModule>
               </
modules>
            </
args>
         </
customer>
      </
routers>
   </
frontend>
</
config>

/app/code/local/MyCompany/MyModule/controllers/AccountController.php

include_once("Mage/Customer/controllers/AccountController.php");
class 
MyCompany_MyModule_AccountController extends Mage_Customer_AccountController
{
   
public function loginAction()
   
{
      
// Do Something
      
parent::loginAction();
   
}
}
 
Magento Community Magento Community
Magento Community
Magento Community
 
LeeSaferite
Guru
 
Avatar
Total Posts:  322
Joined:  2007-08-31
Lake City, FL
 

For anyone that doesn’t know already.  LKC_ModularRouters does not work with 1.3 due to a change in the core routers that Varien implemented.  They added the ability for a single ‘frontname’ to be used by multiple modules via the XML config files.  They did not address the namespacing issues are anything else, but you now have the ability to override core controllers.  If you override a core controller and do not extend the underlying core module, it will try to load the action from your controller and then fail through to the normal core controller.

To recap:
LKC_ModularRouters is currently not 1.3 compatible
Varien added the ability for a single ‘frontname’ to resolve to multiple modules
You can define order on stacked modules via ‘before’ and ‘after’ attributes that contain module names (like Mage_Customer or Mage_Adminhtml)
You can either extend the controller you are overriding, or just implement a controller/action from scratch and allow other actions to pass over to the underlying controller
My module will really only provide namespacing and an alternative override ability starting with the 1.3 compatable version.

 
Magento Community Magento Community
Magento Community
Magento Community
 
G-rom
Jr. Member
 
Total Posts:  15
Joined:  2009-03-06
 

Thank you very much Lee, this new way to overload controller works so fine !

 
Magento Community Magento Community
Magento Community
Magento Community
 
NafeX
Member
 
Total Posts:  47
Joined:  2007-12-18
 

I’m sorry but I don’t get this to work :-(
How can I add a new action to Mage_Adminhtml_Sales_OrderController ?

Lee could you give me one more example please.

Thank you very much.

 
Magento Community Magento Community
Magento Community
Magento Community
 
circa1977
Member
 
Total Posts:  65
Joined:  2008-03-01
 

Lee: Thanks for posting these.

They sort of work for me. We have 1 “from scratch” action and this method supports its call. However, there’s now a bug in it that I fear is due to something that’s just....missing in the request. I’m baffled. Everything should be there, but an underlying function is failing. (This action allows us to add multiple products to cart based on a querystring of SKUs/quantities).

For the two existing controller actions we overrode (ProductController and CategoryController) I cannot get the controllers to fire. I gave up on these and hacked our overrides into the core code. Is that “parent::...” required? Do the modules need to be referenced in their own app/etc/modules? Or can they be referenced in MyCompany_All?

Mark

 
Magento Community Magento Community
Magento Community
Magento Community
 
demonkoryu
Guru
 
Avatar
Total Posts:  328
Joined:  2008-11-26
Dortmund, Germany
 

@Lee: Thanks, you’re a fountain of knowledge as always. smile

 
Magento Community Magento Community
Magento Community
Magento Community
 
GrG
Member
 
Total Posts:  41
Joined:  2008-11-12
 

It’s a very very interesting improvement !

Thank you so much Lee for sharing your knowledge. It would have been nice to read it in a kind of official detailed changelog… (Maybe I missed it ?)

Kind regards,

Greg

 
Magento Community Magento Community
Magento Community
Magento Community
 
J_T_
Mentor
 
Avatar
Total Posts:  1961
Joined:  2008-08-07
London-ish, UK
 
Lee Saferite - 19 April 2009 01:20 PM

Try something like this (Without my module)

/app/code/local/MyCompany/MyModule/etc/config.xml

<config>
   <
frontend>
      <
routers>
         <
customer>
            <
args>
               <
modules>
                  <
MyCompany_MyModule before="Mage_Customer">MyCompany_MyModule<MyCompany_MyModule>
               </
modules>
            </
args>
         </
customer>
      </
routers>
   </
frontend>
</
config>

/app/code/local/MyCompany/MyModule/controllers/AccountController.php
include_once("Mage/Customer/controllers/AccountController.php");
class 
MyCompany_MyModule_AccountController extends Mage_Customer_AccountController
{
   
public function loginAction()
   
{
      
// Do Something
      
parent::loginAction();
   
}
}

I’m struggling to get a Module going that overrides the AdminHtml_controllers_Sales_OrderController.php

Using Lee’s suggested setup as well as trying many other variations, this is what I have so far, that doesn’t work:

“app/etc/modules/JT_Internalcomments.xml”

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

“app/code/local/JT/Internalcomments/etc/config.xml”

<?xml version="1.0"?>
<config>
    <
modules>
        <
JT_Internalcomments>
            <
version>0.1.0</version>
        </
JT_Internalcomments>
    </
modules>
    <
admin>
        <
routers>
            <
jt_internalcomments>
                <use>
admin</use>
                <
args>
                    <
module>JT_Internalcomments</module>
                    <
frontName>internalcomments</frontName>
                </
args>
            </
jt_internalcomments>
        </
routers>
    </
admin>
</
config>

“app/code/local/JT/Internalcomments/controllers/Sales/OrderController.php”

<?php

include_once("Mage/Adminhtml/controllers/Sales/OrderController.php");

class 
JT_Internalcomments_Sales_OrderController extends Mage_Adminhtml_Sales_OrderController
{
    
public function addCommentAction()
    
{
        
if ($order $this->_initOrder()) {
            
try {
                $response 
false;
                
$data $this->getRequest()->getPost('history');
                
$notify = isset($data['is_customer_notified']) ? $data['is_customer_notified'false;
                
$order->addStatusToHistory($data['status']'If this shows, it works! ' $data['comment']$notify); //Note hard-coded test string
                
$comment trim(strip_tags($data['comment']));

                
$order->sendOrderUpdateEmail($notify$comment);
                
$order->save();

                
$this->loadLayout('empty');
                
$this->renderLayout();
            
}
            
catch (Mage_Core_Exception $e{
                $response 
= array(
                    
'error'     => true,
                    
'message'   => $e->getMessage(),
                );
            
}
            
catch (Exception $e{
                $response 
= array(
                    
'error'     => true,
                    
'message'   => $this->__('Can not add order history.')
                );
            
}
            
if (is_array($response)) {
                $response 
Zend_Json::encode($response);
                
$this->getResponse()->setBody($response);
            
}
        }
    }
}

?>

The Module shows in the admin as enabled yet my test when submitting an order comment doesn’t work. Edit the core controller and it does. So somehow, somewhere, it’s not picking up on this class extension / controller override. Any hints?

 
Magento Community Magento Community
Magento Community
Magento Community
 
demonkoryu
Guru
 
Avatar
Total Posts:  328
Joined:  2008-11-26
Dortmund, Germany
 

Hi J.T.,

try this:

<?xml version="1.0"?>
<config>
    <
admin>
        <
routers>
            <
adminhtml>
                <
args>
                    <
modules>
                        <
JT_Internalcomments before="Mage_Adminhtml">JT_Internalcomments</JT_Internalcomments>
                    </
modules>
                </
args>
            </
adminhtml>
        </
routers>
    </
admin>
</
config>
 
Magento Community Magento Community
Magento Community
Magento Community
 
J_T_
Mentor
 
Avatar
Total Posts:  1961
Joined:  2008-08-07
London-ish, UK
 

Thanks Nightfly, as I’ve come to expect form you, that works brilliantly! Code nearly finished…

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top
Page 1 of 2