致命错误:在public_html/app/code/code/core/mage/catalog/model/product.php上,在第1390号线上的非对象上拨打成员函数getsource()
-
16-10-2019 - |
题
我正在尝试使用自定义/否属性来显示/隐藏price.phtml文件中的元素,但是每当我添加条件时,我都会遇到此错误,并且我不明白为什么我以前工作了。
这是我从Price.phtml的第359行中添加的内容
<?php if ($_taxHelper->displayBothPrices()): ?>
<p class="special-price">
<span class="price-label"><?php echo $_specialPriceStoreLabel ?></span>
<span class="price-excluding-tax">
<span class="label"><?php echo $this->helper('tax')->__('Excl. Tax:') ?></span>
<span class="price" id="price-excluding-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>">
<?php echo $_coreHelper->currency($_finalPrice, true, false) ?>
</span>
</span>
<span class="price-including-tax">
<span class="label"><?php echo $this->helper('tax')->__('Incl. Tax:') ?></span>
<span class="price" id="price-including-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>">
<?php echo $_coreHelper->currency($_finalPriceInclTax, true, false) ?>
</span>
</span>
</p>
<?php else: ?>
<?php if ($_product->getAttributeText($_specialPriceStoreLabel['hide_special_price']) == "Yes"): ?>
<span class="del" style="display: none;"><?php echo $this->__('RRP') ?> <?php echo $_coreHelper->currency($_regularPrice, true, false) ?><?php $regularprice = $_regularPrice; ?></span>
<?php $price_diff = $regularprice-$finalPrice;
$discountPercent = ($price_diff/$regularprice)*100;
$discountPercent = ceil($discountPercent); ?>
<span class="discount" style="display: none;">(-<?php echo $discountPercent; ?>%)</span>
<?php else: ?>
<span class="del"><?php echo $this->__('RRP') ?> <?php echo $_coreHelper->currency($_regularPrice, true, false) ?><?php $regularprice = $_regularPrice; ?></span>
<?php $price_diff = $regularprice-$finalPrice;
$discountPercent = ($price_diff/$regularprice)*100;
$discountPercent = ceil($discountPercent); ?>
<span class="discount">(-<?php echo $discountPercent; ?>%)</span>
<?php endif; ?>
<?php endif; ?>
<?php endif; ?>
基本上,我想实现的目标是添加一个新属性并将其添加到我可以设置的价格组中,无论是否在某些产品上显示特殊价格。
我一直遇到这个错误:
function getSource() on a non-object in /*****/*****/public_html/app/code/core/Mage/Catalog/Model/Product.php on line 1390
谁能看到我做错了什么?
解决方案
这条线是不正确的,导致问题:
if($_product->getAttributeText($_specialPriceStoreLabel['hide_special_price']) == "Yes")
这样使用:
if($_product->getHideSpecialPrice())
或者
if($_product->getData('hide_special_price'))
和您的属性 hide_special_price
应该 “用于产品清单” 和 “在前端的产品查看页面上可见” (请参阅属性编辑页面)。