2
votes

I see the following error when opening the page of one of our shop items. In the current template it doesn't work, in another plain template it does. The problem may be caused by an upgrade from magento 1.4 to 1.7.

Can anyone explain what this means and what is happening? How can I fix this?

a:5:{i:0;s:109:"Invalid method Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option_Radio::_getDefaultValues(Array ( ) )";i:1;s:7069:"#0 /www/htdocs/app/design/frontend/base/default/template/bundle/catalog/product/view/type/bundle/option/radio.phtml(33): Varien_Object->__call('_getDefaultValu...', Array)

Below the complete error report. The product is part of a bundle.

a:5:{i:0;s:109:"Invalid method Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option_Radio::_getDefaultValues(Array
(
)
)";i:1;s:7069:"#0 /www/htdocs/app/design/frontend/base/default/template/bundle/catalog/product/view/type/bundle/option/radio.phtml(33): Varien_Object->__call('_getDefaultValu...', Array)

#1 /www/htdocs/app/design/frontend/base/default/template/bundle/catalog/product/view/type/bundle/option/radio.phtml(33): Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option_Radio->_getDefaultValues()
#2 /www/htdocs/app/code/core/Mage/Core/Block/Template.php(241): include('/www/ht...')
#3 /www/htdocs/app/code/core/Mage/Core/Block/Template.php(272): Mage_Core_Block_Template->fetchView('frontend/base/d...')
#4 /www/htdocs/app/code/core/Mage/Core/Block/Template.php(286): Mage_Core_Block_Template->renderView()
#5 /www/htdocs/app/code/core/Mage/Catalog/Block/Product/Price.php(154): Mage_Core_Block_Template->_toHtml()
#6 /www/htdocs/app/code/core/Mage/Bundle/Block/Catalog/Product/Price.php(97): Mage_Catalog_Block_Product_Price->_toHtml()
#7 /www/htdocs/app/code/core/Mage/Core/Block/Abstract.php(863): Mage_Bundle_Block_Catalog_Product_Price->_toHtml()
#8 /www/htdocs/app/code/core/Mage/Bundle/Block/Catalog/Product/View/Type/Bundle.php(216): Mage_Core_Block_Abstract->toHtml()
#9 /www/htdocs/app/design/frontend/base/default/template/bundle/catalog/product/view/type/bundle/options.phtml(37): Mage_Bundle_Block_Catalog_Product_View_Type_Bundle->getOptionHtml(Object(Mage_Bundle_Model_Option))
#10 /www/htdocs/app/code/core/Mage/Core/Block/Template.php(241): include('/www/ht...')
#11 /www/htdocs/app/code/core/Mage/Core/Block/Template.php(272): Mage_Core_Block_Template->fetchView('frontend/base/d...')
#12 /www/htdocs/app/code/core/Mage/Core/Block/Template.php(286): Mage_Core_Block_Template->renderView()
#13 /www/htdocs/app/code/core/Mage/Core/Block/Abstract.php(863): Mage_Core_Block_Template->_toHtml()
#14 /www/htdocs/app/code/core/Mage/Core/Block/Abstract.php(582): Mage_Core_Block_Abstract->toHtml()
#15 /www/htdocs/app/code/core/Mage/Core/Block/Abstract.php(522): Mage_Core_Block_Abstract->_getChildHtml('product.info.bu...', true)
#16 /www/htdocs/app/design/frontend/base/default/template/catalog/product/view/options/wrapper.phtml(28): Mage_Core_Block_Abstract->getChildHtml('', true, true)
#17 /www/htdocs/app/code/core/Mage/Core/Block/Template.php(241): include('/www/ht...')
#18 /www/htdocs/app/code/core/Mage/Core/Block/Template.php(272): Mage_Core_Block_Template->fetchView('frontend/base/d...')
#19 /www/htdocs/app/code/core/Mage/Core/Block/Template.php(286): Mage_Core_Block_Template->renderView()
#20 /www/htdocs/app/code/core/Mage/Core/Block/Abstract.php(863): Mage_Core_Block_Template->_toHtml()
#21 /www/htdocs/app/code/core/Mage/Core/Block/Abstract.php(582): Mage_Core_Block_Abstract->toHtml()
#22 /www/htdocs/app/code/core/Mage/Core/Block/Abstract.php(522): Mage_Core_Block_Abstract->_getChildHtml('product.info.op...', true)
#23 /www/htdocs/app/code/core/Mage/Core/Block/Abstract.php(546): Mage_Core_Block_Abstract->getChildHtml('', true, true)
#24 /www/htdocs/app/design/frontend/default/shoestore/template/catalog/product/view.phtml(101): Mage_Core_Block_Abstract->getChildChildHtml('container2', '', true, true)
#25 /www/htdocs/app/code/core/Mage/Core/Block/Template.php(241): include('/www/ht...')
#26 /www/htdocs/app/code/core/Mage/Core/Block/Template.php(272): Mage_Core_Block_Template->fetchView('frontend/defaul...')
#27 /www/htdocs/app/code/core/Mage/Core/Block/Template.php(286): Mage_Core_Block_Template->renderView()
#28 /www/htdocs/app/code/core/Mage/Core/Block/Abstract.php(863): Mage_Core_Block_Template->_toHtml()
#29 /www/htdocs/app/code/core/Mage/Core/Block/Text/List.php(43): Mage_Core_Block_Abstract->toHtml()
#30 /www/htdocs/app/code/core/Mage/Core/Block/Abstract.php(863): Mage_Core_Block_Text_List->_toHtml()
#31 /www/htdocs/app/code/core/Mage/Core/Block/Abstract.php(582): Mage_Core_Block_Abstract->toHtml()
#32 /www/htdocs/app/code/core/Mage/Core/Block/Abstract.php(526): Mage_Core_Block_Abstract->_getChildHtml('content', true)
#32 /www/htdocs/app/code/core/Mage/Core/Block/Abstract.php(526): Mage_Core_Block_Abstract->_getChildHtml('content', true)
#33 /www/htdocs/app/design/frontend/base/default/template/page/2columns-right.phtml(48): Mage_Core_Block_Abstract->getChildHtml('content')
#34 /www/htdocs/app/code/core/Mage/Core/Block/Template.php(241): include('/www/ht...')
#35 /www/htdocs/app/code/core/Mage/Core/Block/Template.php(272): Mage_Core_Block_Template->fetchView('frontend/base/d...')
#36 /www/htdocs/app/code/core/Mage/Core/Block/Template.php(286): Mage_Core_Block_Template->renderView()
#37 /www/htdocs/app/code/core/Mage/Core/Block/Abstract.php(863): Mage_Core_Block_Template->_toHtml()
#38 /www/htdocs/app/code/core/Mage/Core/Model/Layout.php(555): Mage_Core_Block_Abstract->toHtml()
#39 /www/htdocs/app/code/core/Mage/Core/Controller/Varien/Action.php(390): Mage_Core_Model_Layout->getOutput()
#40 /www/htdocs/app/code/core/Mage/Cms/Helper/Page.php(137): Mage_Core_Controller_Varien_Action->renderLayout()
#41 /www/htdocs/app/code/core/Mage/Cms/Helper/Page.php(52): Mage_Cms_Helper_Page->_renderPage(Object(Mage_Cms_IndexController), 'no-route')
#42 /www/htdocs/app/code/core/Mage/Cms/controllers/IndexController.php(75): Mage_Cms_Helper_Page->renderPage(Object(Mage_Cms_IndexController), 'no-route')
#43 /www/htdocs/app/code/core/Mage/Core/Controller/Varien/Action.php(419): Mage_Cms_IndexController->noRouteAction()
#44 /www/htdocs/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch('noRoute')
#45 /www/htdocs/app/code/core/Mage/Core/Controller/Varien/Front.php(176): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#46 /www/htdocs/app/code/core/Mage/Core/Model/App.php(354): Mage_Core_Controller_Varien_Front->dispatch()
#47 /www/htdocs/app/Mage.php(683): Mage_Core_Model_App->run(Array)
#48 /www/htdocs/index.php(119): Mage::run('', 'store')
#49 {main}";s:3:"url";s:26:"/nike-bw-black.html";s:11:"script_name";s:10:"/index.php";s:4:"skin";s:7:"default";}

The code of the phtml file: http://pastebin.com/6CGq3nSR

2
Something on that page you are loading uses radio buttons in a form and something related to that isn't working. As in, the default radio button that is set to be selected is not appearing in the form containing the options. Perhaps it is product options? Who knows. You would receive more help if you provided a link to where this is happening or more information.zigojacko
Thank you. I added the complete error report. I've noticed that this error doesn't appear when using another template.SPRBRN
Paste the phtml file content here pleaseMeabed
I tried to paste the phtml code, but that doesn't work properly as you can see. I've used <pre> tags around it. Here you can see how it should look: pastebin.com/6CGq3nSRSPRBRN

2 Answers

7
votes

It sounds like you have mismatched code from different version of Magento running in your system. It's also possible you have a compiled version of an old class, or a community/local code pool override. This is going to be long, so I'll try to call out the specific debugging tips with bold text

As the other answers have made clear, PHP is telling you the exact problem.

Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option_Radio::_getDefaultValues

Magento is trying to call the _getDefaultValues method on your Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option_Radio object. However, in your system, this object doesn't have this method. If I look at a fresh install of Magento 1.7.0.1 , this class is defined in

#File: app/code/core/Mage/Bundle/Block/Catalog/Product/View/Type/Bundle/Option/Radio.php
class Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option_Radio
    extends Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option
{
    /**
     * Set template
     *
     * @return void
     */
    protected function _construct()
    {
        $this->setTemplate('bundle/catalog/product/view/type/bundle/option/radio.phtml');
    }
}

and in its parent class Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option, we can find the definition of _getDefaultValues

#File: app/code/core/Mage/Bundle/Block/Catalog/Product/View/Type/Bundle/Option.php
class Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option extends Mage_Bundle_Block_Catalog_Product_Price
{
    protected function _getDefaultValues()
    {
        //...
    }
}    

Protected methods are callable from a block's template, so this means this is not a bug with the shipping version of Magento, but is instead a problem with your system.

Debugging Step 1: The first thing to check would be your version of the file

app/code/core/Mage/Bundle/Block/Catalog/Product/View/Type/Bundle/Option.php

Does this file have a _getDefaultValues method? If not, of if it's private instead of protected, then the problem is your version of the phtml template is from one version of Magento, but your core class file is from another, or has been modified. You could try downloading a fresh copy of the Magento version you're running and replacing the file — but your system may have other problems if this was a botched upgrade, so be ready for that. Fixing that is larger than a single Stack Overflow question.

Debugging Step 2: Check your local and community code pools.

Magento allows you to replace class files by using the app/code/community and app/code/local code pools. Your system may have a version of this class file that's in one of these pools. Check for a file in

app/code/community/Mage/Bundle/Block/Catalog/Product/View/Type/Bundle/Option.php
app/code/local/Mage/Bundle/Block/Catalog/Product/View/Type/Bundle/Option.php

and if there's a file, check for the _getDefaultValues method. If it's not there, or if it's private instead of protected, you've found your problem. Fixing this will, again, be tricky. If the file was placed here it means a previous developer added or changed methods. You could fix your error above by removing the local or community file, but then you'd lose this custom functionality. You'll need to merge a correct core file in with your local/community file OR you'll need to identify the extra functionality in your local/community file and refactor these to use class rewrites, and only then remove the file. Again, that's a process that's more complicated than a single stack overflow answer.

Debugging Step 3: Turn off compilation.

It's also possible that Magento is running in "compiled" mode, and that the "compiled" version of your class. Turn off compilation mode from

System -> Tools -> Compilation

or from the command line with

$ php shell/compiler.php disable

and recompile you classes.

Debugging Step 4: Clear opt code cache.

If you're running a system like APC to cache PHP opt code, it may be an old version of the class is in the opt code cache. As there's numerous options here, I'll leave the clearing of this cache as an exercise for the reader.

Debugging Step 5: Use reflection to identify the class file

If you still haven't identified the rouge class at this point, add the following code to the bottom of index.php

$o = Mage::getSingleton('core/layout')->createBlock('bundle/catalog_product_view_type_bundle_option_radio');
$r = new ReflectionClass($o);
echo '<h1>';
var_dump(get_class($o));
var_dump($r->getFilename());
echo '</h1>';

This will instantiate a block class and use reflection to tell you where it's definition file is. From there, you can figure out why this is the wrong definition file, and what you'll need to do to remove it.

2
votes

You seems to be calling a non existing method on an object of type Mage_[...]_Radio.

The class Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option_Radio does not have any public method called _getDefaultValues.


After a little bit of research I've found that the method actually exists in that class but its visibility is protected therefore to access it you inherit from the Mage_[...]_Radio class and make it public accessible or leave it protected:

class YourClass extends Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option_Radio {
    public function getDefaultValues() { return $this->_getDefaultValues(); }
}