我收到了以下错误,但它在Magento核心中说明了这一点。我想知道如何调试这个,因为我确信Magentos核心没有任何问题。
这是错误:
30-Apr-2018 18:05:23 UTC] PHP Fatal error: Uncaught Error: Call to a member function getMetaTitle() on null in /home/example/public_html/app/code/core/Mage/Catalog/Block/Product/View.php:18
Stack trace:
#0 /home/example/public_html/app/code/core/Mage/Core/Block/Abstract.php(139): Mage_Catalog_Block_Product_View->_prepareLayout()
#1 /home/example/public_html/app/code/core/Mage/Core/Model/Layout.php(322): Mage_Core_Block_Abstract->setLayout(Object(Inchoo_PHP7_Model_Layout))
#2 /home/example/public_html/app/code/core/Mage/Core/Model/Layout.php(332): Mage_Core_Model_Layout->createBlock('review/product_...', 'product.info')
#3 /home/example/public_html/app/code/core/Mage/Core/Model/Layout.php(147): Mage_Core_Model_Layout->addBlock('review/product_...', 'product.info')
#4 /home/example/public_html/app/code/core/Mage/Core/Model/Layout.php(119): Mage_Core_Model_Layout->_generateBlock(Object(Mage_Core_Model_Layout_Element), Object(Mage_Core_Model_Layout_Element))
#5 /home/example/public_html/app/co in /home/example/public_html/app/code/core/Mage/Catalog/Block/Product/View.php on line 18
以下是/home/angelsforeveryon/public_html/app/code/core/Mage/Catalog/Block/Product/View.php:18
protected function _prepareLayout()
{
$this->getLayout()->createBlock('catalog/breadcrumbs');
$headBlock = $this->getLayout()->getBlock('head');
if ($headBlock) {
$product = $this->getProduct();
line 18 here --> $title = $product->getMetaTitle();
if ($title) {
$headBlock->setTitle($title);
}
$keyword = $product->getMetaKeyword();
$currentCategory = Mage::registry('current_category');
if ($keyword) {
$headBlock->setKeywords($keyword);
} elseif ($currentCategory) {
$headBlock->setKeywords($product->getName());
}
$description = $product->getMetaDescription();
if ($description) {
$headBlock->setDescription( ($description) );
} else {
$headBlock->setDescription(Mage::helper('core/string')->substr($product->getDescription(), 0, 255));
}
if ($this->helper('catalog/product')->canUseCanonicalTag()) {
$params = array('_ignore_category' => true);
$headBlock->addLinkRel('canonical', $product->getUrlModel()->getUrl($product, $params));
}
}
return parent::_prepareLayout();
}
谢谢
答案 0 :(得分:0)
看起来您的产品为空,您需要确保此功能正常运行
$ product = $ this-> getProduct();