开发者

Invalid method Mage_Catalog_Block_Product_Price::testPrice(Array(

I am trying to control the price text from Magento Admin panel and for that I have overwritten default/template/catalog/product/price.phtml and trying to change the line:

<span class="price-label"><?php echo $this->__('Regular Price:') ?></span>

to

<span class="price-label"><?php $this->newPriceText(); ?></span>

I have created newPriceText(); method in local/MyCompany/Catalog/Block/Product/Price.php, which looks like this at the moment:

class MyCompany_Catalog_Block_Product_Price extends Mage_Catalog_Block_Product_Price
{
    public function newPriceText()
    {
        print_r('Testing Price Text');
    }

but I'm getting the following error:

a:5:{i:0;s:70:"Invalid method Mage_Catalog_Block_Product_Price::testPrice(Array
(
)
)";i:1;s:4859:"#0 [internal function]: Varien_Object->__call('testPrice', Array)
#1 C:\wamp\www\mage_testing\app\design\frontend\default\default\template\catalog\product\price.phtml(320): Mage_Catalog_Block_Product_Price->testPrice()
#2 C:\wamp\www\mage_testing\app\code\core\Mage\Core\Block\Template.php(235): include('C:\wamp\www\mag...')
#3 C:\wamp\www\mage_testing\app\code\core\Mage\Core\Block\Template.php(266): Mage_Core_Block_Template->fetchView('frontend\defaul...')
#4 C:\wamp\www\mage_testing\app\code\core\Mage\Core\Block\Template.php(280): Mage_Core_Block_Template->renderView()
#5 C:\wamp\www\mage_testing\app\code\core\Mage\Catalog\Block\Product\Price.php(111): Mage_Core_Block_Template->_toHtml()
#6 C:\wamp\www\mage_testing\app\code\core\Mage\Core\Block\Abstract.php(758): Mage_Catalog_Block_Product_Price->_toHtml()
#7 C:\wamp\www\mage_testing\app\code\core\Mage\Catalog\Block\Product\Abstract.php(203): Mage_Core_Block_Abstract->toHtml()
#8 C:\wamp\www\mage_testing\app\design\frontend\base\default\template\catalog\product\list.phtml(100): Mage_Catalog_Block_Product_Abstract->getPriceHtml(Object(Mage_Catalog_Model_Product), true)
#9 C:\wamp\www\mage_testing\app\code\core\Mage\Core\Block\Template.php(235): include('C:\wamp\www\mag...')
#10 C:\wamp\www\mage_testing\app\code\core\Mage\Core\Block\Template.php(266): Mage_Core_Block_Template->fetchView('frontend\base\d...')
#11 C:\wamp\www\mage_testing\app\code\core\Mage\Core\Block\Template.php(280): Mage_Core_Block_Template->renderView()
#12 C:\wamp\www\mage_testing\app\code\core\Mage\Core\Block\Abstract.php(758): Mage_Core_Block_Template->_toHtml()
#13 C:\wamp\www\mage_testing\app\code\core\Mage\Core\Block\Abstract.php(525): Mage_Core_Block_Abstract->toHtml()
#14 C:\wamp\www\mage_testing\app\code\core\Mage\Core\Block\Abstract.php(476): Mage_Core_Block_Abstract->_getChildHtml('product_list', true)
#15 C:\wamp\www\mage_testing\app\code\core\Mage\Catalog\Block\Category\View.php(85): Mage_Core_Block_Abstract->getChildHtml('product_list')
#16 C:\wamp\www\mage_testing\app\design\frontend\base\default\template\catalog\category\view.phtml(70): Mage_Catalog_Block_Category_View->getProductListHtml()
#17 C:\wamp\www\mage_testing\app\code\core\Mage\Core\Block\Template.php(235): include('C:\wamp\www\mag...')
#18 C:\wamp\www\mage_testing\app\code\core\Mage\Core\Block\Template.php(266): Mage_Core_Block_Template->fetchView('frontend\base\d...')
#19 C:\wamp\www\mage_testing\app\code\core\Mage\Core\Block\Template.php(280): Mage_Core_Block_Template->renderView()
#20 C:\wamp\www\mage_testing\app\code\core\Mage\Core\Block\Abstract.php(758): Mage_Core_Block_Template->_toHtml()
#21 C:\wamp\www\mage_testing\app\code\core\Mage\Core\Block\Text\List.php(43): Mage_Core_Block_Abstract->toHtml()
#22 C:\wamp\www\mage_testing\app\code\core\Mage\Core\Block\Abstract.php(758): Mage_Core_Block_Text_List->_toHtml()
#23 C:\wamp\www\mage_testing\app\code\core\Mage\Core\Block\Abstract.php(525): Mage_开发者_高级运维Core_Block_Abstract->toHtml()
#24 C:\wamp\www\mage_testing\app\code\core\Mage\Core\Block\Abstract.php(476): Mage_Core_Block_Abstract->_getChildHtml('content', true)
#25 C:\wamp\www\mage_testing\app\design\frontend\base\default\template\page\3columns.phtml(49): Mage_Core_Block_Abstract->getChildHtml('content')
#26 C:\wamp\www\mage_testing\app\code\core\Mage\Core\Block\Template.php(235): include('C:\wamp\www\mag...')
#27 C:\wamp\www\mage_testing\app\code\core\Mage\Core\Block\Template.php(266): Mage_Core_Block_Template->fetchView('frontend\base\d...')
#28 C:\wamp\www\mage_testing\app\code\core\Mage\Core\Block\Template.php(280): Mage_Core_Block_Template->renderView()
#29 C:\wamp\www\mage_testing\app\code\core\Mage\Core\Block\Abstract.php(758): Mage_Core_Block_Template->_toHtml()
#30 C:\wamp\www\mage_testing\app\code\core\Mage\Core\Model\Layout.php(529): Mage_Core_Block_Abstract->toHtml()
#31 C:\wamp\www\mage_testing\app\code\core\Mage\Core\Controller\Varien\Action.php(391): Mage_Core_Model_Layout->getOutput()
#32 C:\wamp\www\mage_testing\app\code\core\Mage\Catalog\controllers\CategoryController.php(159): Mage_Core_Controller_Varien_Action->renderLayout()
#33 C:\wamp\www\mage_testing\app\code\core\Mage\Core\Controller\Varien\Action.php(420): Mage_Catalog_CategoryController->viewAction()
#34 C:\wamp\www\mage_testing\app\code\core\Mage\Core\Controller\Varien\Router\Standard.php(253): Mage_Core_Controller_Varien_Action->dispatch('view')
#35 C:\wamp\www\mage_testing\app\code\core\Mage\Core\Controller\Varien\Front.php(176): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#36 C:\wamp\www\mage_testing\app\code\core\Mage\Core\Model\App.php(340): Mage_Core_Controller_Varien_Front->dispatch()
#37 C:\wamp\www\mage_testing\app\Mage.php(627): Mage_Core_Model_App->run(Array)
#38 C:\wamp\www\mage_testing\index.php(80): Mage::run('', 'store')
#39 {main}";s:3:"url";s:27:"/mage_testing/products.html";s:11:"script_name";s:23:"/mage_testing/index.php";s:4:"skin";s:7:"default";}


}

I'm not sure where I'm doing it wrong. Any idea?

I'm still waiting for the answer. Please help?

"I am not sure how to write the layout xml for this."


Your trace says:

Invalid method Mage_Catalog_Block_Product_Price::testPrice(Array())

which is different from the method newPriceText() that you have defined in the block and are also calling in your template.

Scan your template for testPrice() or $this->testPrice() calls.

Maybe you originally had defined a method named testPrice, then deleted it, or changed its name to newPriceText afterwards, but forgot to remove/rename the method calls in your template accordingly.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜