致命的な誤り:public_html/app/code/core/Mage/Catalog/Model/Product.php の 1390 行目で、非オブジェクトのメンバー関数 getSource() を呼び出します。

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

質問

カスタムの Yes/No 属性を使用して、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 あるべきです 「商品リストに使用」 そして 「フロントエンドの製品表示ページに表示されます」 (属性編集ページを参照)。

ライセンス: CC-BY-SA帰属
所属していません magento.stackexchange
scroll top