Fatal error: Appel à une fonction membre getSource () sur un non-objet dans public_html / app / code / core / Mage / Catalogue / Modèles / product.php à la ligne 1390

magento.stackexchange https://magento.stackexchange.com/questions/13293

Question

Je suis en train d'utiliser une commande Oui / Non attribut pour afficher / masquer un élément dans le fichier Price.phtml mais chaque fois que j'ajouter la condition que je continue à obtenir cette erreur et je ne peux pas comprendre pourquoi depuis que je l'avais déjà travailler .

Voici ce que j'ai ajouté de la ligne 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; ?>

En fait ce que je voudrais réaliser est en ajoutant un nouvel attribut et l'ajouter au groupe de prix que je peux choisir d'afficher le prix spécial sur le frontend ou non pour certains produits.

Je continue à obtenir cette erreur:

function getSource() on a non-object in /*****/*****/public_html/app/code/core/Mage/Catalog/Model/Product.php on line 1390

Quelqu'un peut-il voir ce que je l'ai fait mal?

Était-ce utile?

La solution

Cette ligne est incorrecte Wich la cause du problème:

if($_product->getAttributeText($_specialPriceStoreLabel['hide_special_price']) == "Yes")

Utilisez comme ceci:

if($_product->getHideSpecialPrice())

ou

if($_product->getData('hide_special_price'))

Et votre hide_special_price attribut doit être "Utilisé dans la liste des produits" et "Visible sur le produit Voir la page en fin avant" (voir page d'édition d'attribut).

Licencié sous: CC-BY-SA avec attribution
Non affilié à magento.stackexchange
scroll top