0
我们正面临着致命的错误在购物车页面:致命错误:调用一个成员函数isVirtual()一个非对象
Fatal error: Call to a member function isVirtual() on a non-object in
return $this->getConfig()->isEnabled() && !$this->getProduct()->isVirtual();
全码:app/code/community/WebDevlopers/ProductPageShipping/Block/Estimate/Abstract.php
<?php
abstract class WebDevlopers_ProductPageShipping_Block_Estimate_Abstract extends Mage_Catalog_Block_Product_Abstract
{
protected $_estimate = null;
protected $_config = null;
protected $_session = null;
protected $_carriers = null;
public function getEstimate()
{
if ($this->_estimate === null) {
$this->_estimate = Mage::getSingleton('webdevlopers_productpageshipping/estimate');
}
return $this->_estimate;
}
public function getConfig()
{
if ($this->_config === null) {
$this->_config = Mage::getSingleton('webdevlopers_productpageshipping/config');
}
return $this->_config;
}
public function getSession()
{
if ($this->_session === null) {
$this->_session = Mage::getSingleton('webdevlopers_productpageshipping/session');
}
return $this->_session;
}
public function isEnabled()
{
return $this->getConfig()->isEnabled() && !$this->getProduct()->isVirtual();
}
}
首先,这是你自己的扩展?如果是这样,你在什么情况下调用该块?因为它从一个Product块扩展而来,所以你应该总是能够调用'$ this-> getProduct()'而不用返回false/null。快速获胜将是'return $ this-> getConfig() - > isEnabled()&& $ this-> getProduct()&&!$ this-> getProduct() - > isVirtual();'a la check'getProduct() '在使用之前返回一个真理 –
@RobbieAverill这不是我的扩展。你可以告诉我什么代码,我需要用'return $ this-> getConfig() - > isEnabled()&&!$ this-> getProduct() - > isVirtual();' – fresher
代替我刚刚给你的代码: )与任何人编写扩展名,并让他们修复它。如果你愿意的话,我可以解释一下你如何使一个*本地*模型覆盖,以防止黑客攻击一个社区类,但要确保这个修改是首先运行的,否则它不值得做。 –