我正在尝试从Magento Admin面板控制价格文本,为此我覆盖了default / template / catalog / product / price.phtml并尝试更改该行:
<span class="price-label"><?php echo $this->__('Regular Price:') ?></span>
到
<span class="price-label"><?php $this->newPriceText(); ?></span>
我创建了newPriceText(); local / MyCompany / Catalog / Block / Product / Price.php中的方法,目前看起来像这样:
class MyCompany_Catalog_Block_Product_Price extends Mage_Catalog_Block_Product_Price
{
public function newPriceText()
{
print_r('Testing Price Text');
}
但我收到以下错误:
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";}
}
我不确定我做错了什么。有什么想法吗?
我还在等待答案。请帮帮忙?
“我不知道如何为此编写布局xml。”
答案 0 :(得分:0)
你的踪迹说:
无效方法Mage_Catalog_Block_Product_Price :: testPrice (Array())
与您在块中定义的方法 newPriceText()
不同,并且也在模板中调用。
扫描您的模板以查看testPrice()
或$this->testPrice()
来电。
也许您最初定义了一个名为testPrice
的方法,然后将其删除,或者之后将其名称更改为newPriceText
,但忘记删除/重命名模板中的方法调用。