Error fatal: llame a una función de miembro getSource () en un no objeto en public_html/app/code/core/mage/catalog/model/producto.php en línea 1390
-
16-10-2019 - |
Pregunta
Estoy tratando de utilizar un atributo SÍ/NO personalizado para mostrar/ocultar un elemento dentro del archivo Price.phtml, pero cada vez que agrego la condición, sigo recibiendo este error y no puedo entender por qué ya que lo tenía funcionando anteriormente.
Esto es lo que he agregado de la línea 359 de Price.phtml
<?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; ?>
Básicamente, lo que me gustaría lograr es agregar un nuevo atributo y agregarlo al grupo de precios, puedo establecer si mostrar un precio especial en el interfaz o no para ciertos productos.
Sigo recibiendo este error:
function getSource() on a non-object in /*****/*****/public_html/app/code/core/Mage/Catalog/Model/Product.php on line 1390
¿Alguien puede ver lo que he hecho mal?
Solución
Esta línea es incorrecta que causa el problema:
if($_product->getAttributeText($_specialPriceStoreLabel['hide_special_price']) == "Yes")
Usa así:
if($_product->getHideSpecialPrice())
o
if($_product->getData('hide_special_price'))
Y tu atributo hide_special_price
debiera ser "Usado en la lista de productos" y "Visible en la página Vista de producto en front-end" (Consulte la página de edición de atributos).