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
代替我剛剛給你的代碼: )與任何人編寫擴展名,並讓他們修復它。如果你願意的話,我可以解釋一下你如何使一個*本地*模型覆蓋,以防止黑客攻擊一個社區類,但要確保這個修改是首先運行的,否則它不值得做。 –