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

Can’t override checkout module
 
nxlmage
Jr. Member
 
Total Posts:  3
Joined:  2009-02-07
 

Hi,

I’m trying to override Mage_Checkout_Model_Type_Onepage class, without success. The application stops when it tries to __autoload my derived class and I get this error message:

Warning: include(.php[function.include]failed to open streamNo such file or directory  in I:\Common\Dev\Web\magento\app\code\core\Mage\Core\functions.php on line 73

I did some more digging around and discovered the origin of the problem. The failure occurs in Mage_Core_Model_Config::getGroupedClassName() :

// $groupRootNode = "global/models", $group = "checkout" and $class = "type_onepage"

if (isset($this->_classNameCache[$groupRootNode][$group][$class])) {
  
return $this->_classNameCache[$groupRootNode][$group][$class];
}
$config 
$this->_xml->global->{$groupType.'s'}->{$group};
if (isset(
$config->rewrite->$class)) {
  
// this statement fails: $className="" as a result
  
$className = (string)$config->rewrite->$class;
else {
  
if (!empty($config)) {
    $className 
$config->getClassName();
  
}
  
if (empty($className)) {
    $className 
'mage_'.$group.'_'.$groupType;
  
}
  
if (!empty($class)) {
    $className 
.= '_'.$class;
  
}
  $className 
uc_words($className);
}

When I dump $config, I get the following:

Mage_Core_Model_Config_Element Object
(
    
[class] => Mage_Checkout_Model
    [resourceModel] 
=> checkout_mysql4
    [rewrite] 
=> Mage_Core_Model_Config_Element Object
        
(
            
[type_onepage] => Mage_Core_Model_Config_Element Object
                
(
                    
[class] => MyNamespace_MyModule_Model_Checkout_Type_Onepage
                
)
        )
)
So my derived class seems to be properly registered. I do it this way in config.xml:

<global>
  <
models>
      <
checkout>
        <
rewrite>
            <
type_onepage>
              <class>
MyNameSpace_MyModule_Model_Checkout_Type_Onepage</class>
          </
type_onepage>
        </
rewrite>
      </
checkout>
  </
models>
<global>

While not being a PHP expert, I’m quite unsure of what this statement in Mage_Core_Model_Config::getGroupedClassName() is supposed to do:

$className = (string)$config->rewrite->$class;

But if a replace it with this one:

$className $config->rewrite->$class->getClassName();

$className is ok (="MyNamespace_MyModule_Model_Checkout_Type_Onepage") and my class is then properly loaded and instanciated by the system.

I would really appreciate if someone could point what I’m doing wrong, or if this is a Magento issue.

Thanks.

 
Magento Community Magento Community
Magento Community
Magento Community
 
mzentrale1
Guru
 
Total Posts:  731
Joined:  2007-12-06
Stuttgart, Germany
 

Hi,

try to overwrite model in this way:

<global>
  <
models>
      <
checkout>
        <
rewrite>
            <
type_onepage>
              
MyNameSpace_MyModule_Model_Checkout_Type_Onepage
          
</type_onepage>
        </
rewrite>
      </
checkout>
  </
models>
<global>

cheers

 
Magento Community Magento Community
Magento Community
Magento Community
 
nxlmage
Jr. Member
 
Total Posts:  3
Joined:  2009-02-07
 

Almost got it !
You gave the solution, but due to Magento XML white-space misparsing the class declaration should rather be written like this:

<global>
    <
models>
        <
checkout>
            <
rewrite>
                <
type_onepage>MyNameSpace_MyModule_Model_Checkout_Type_Onepage</type_onepage>
            </
rewrite>
        </
checkout>
    </
models>
</global>

Thank you very much for your help !

 
Magento Community Magento Community
Magento Community
Magento Community
 
Ilango Chokalingam
Jr. Member
 
Total Posts:  10
Joined:  2009-03-05
Germany
 

HI,
I need to develop a custom checkout module for my website. Can you pls tell me or share the code you created for custom checkout module.

I would ike to create a simplified one page checkout module which caters to my needs.

Thanks in advance

Regards
Ilango Chokalingam

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