0

Magento ウェブショップで cron.php を実行すると、次のエラーが表示されます。

PHP 致命的なエラー: 86 行目の app/code/core/Mage/CatalogRule/Model/Observer.php の非オブジェクトに対するメンバー関数 getEvent() の呼び出し

Magento 1.6.2 ウェブショップです。

これは 86 行目です。

$product    = $observer->getEvent()->getProduct();

これは、エラーが発生する関数です。

public function processFrontFinalPrice($observer)
{
    $product    = $observer->getEvent()->getProduct();
    $pId        = $product->getId();
    $storeId    = $product->getStoreId();

    if ($observer->hasDate()) {
        $date = $observer->getEvent()->getDate();
    } else {
        $date = Mage::app()->getLocale()->storeTimeStamp($storeId);
    }

    if ($observer->hasWebsiteId()) {
        $wId = $observer->getEvent()->getWebsiteId();
    } else {
        $wId = Mage::app()->getStore($storeId)->getWebsiteId();
    }

    if ($observer->hasCustomerGroupId()) {
        $gId = $observer->getEvent()->getCustomerGroupId();
    } elseif ($product->hasCustomerGroupId()) {
        $gId = $product->getCustomerGroupId();
    } else {
        $gId = Mage::getSingleton('customer/session')->getCustomerGroupId();
    }

    $key = "$date|$wId|$gId|$pId";
    if (!isset($this->_rulePrices[$key])) {
        $rulePrice = Mage::getResourceModel('catalogrule/rule')
            ->getRulePrice($date, $wId, $gId, $pId);
        $this->_rulePrices[$key] = $rulePrice;
    }
    if ($this->_rulePrices[$key]!==false) {
        $finalPrice = min($product->getData('final_price'), $this->_rulePrices[$key]);
        $product->setFinalPrice($finalPrice);
    }
    return $this;
}

Magento のコア コードは変更されていません。

誰が何がうまくいかないのか知っていますか?

4

1 に答える 1

0

どのイベントをキャッチしようとしていますか?

とにかく私はそれを使用します:うまくいく$product_id = Mage::registry('current_product')->getId(); ようです。

于 2013-10-18T19:05:30.343 に答える