当我为Magento网上商店运行cron.php时,我看到以下错误:
PHP致命错误:在非对象上调用成员函数getEvent() 在app / code / core / Mage / CatalogRule / Model / Observer.php第86行
这是一个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核心代码未作任何修改
有谁知道出了什么问题?
答案 0 :(得分:0)
你想要捕捉什么事件?
无论如何我使用它:$product_id = Mage::registry('current_product')->getId();
它似乎有效。