系统日志错误

时间:2013-12-02 08:44:22

标签: xml magento module product mage

我从这个网站开始关注本教程:http://coding.smashingmagazine.com/2012/03/01/basics-creating-magento-module/ 我必须提到我有与网站中相同的代码。问题是当我在var / log / system.log中创建/更新产品时出现此错误:

"2013-12-02T08:36:36+00:00 ERR (3): Warning: include(C:\xampp\htdocs\mage\magento\includes\src\Mage_Smashingmagazine_Logproductupdate_Model_Observer.php): failed to open stream: No such file or directory  in C:\xampp\htdocs\mage\magento\includes\src\Varien_Autoload.php on line 93
2013-12-02T08:36:36+00:00 ERR (3): Warning: include(): Failed opening 'C:\xampp\htdocs\mage\magento\includes\src\Mage_Smashingmagazine_Logproductupdate_Model_Observer.php' for inclusion (include_path='C:\xampp\htdocs\mage\magento\includes\src;.;C:\xampp\php\pear\;D:\xampp\php\zend1\library')  in C:\xampp\htdocs\mage\magento\includes\src\Varien_Autoload.php on line 93"

谁能告诉我为什么???编译被禁用,我经常清除chache。 Thx提前 / * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * *** /

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <modules>
        <SmashingMagazine_LogProductUpdate>
            <version>0.0.1</version>
        </SmashingMagazine_LogProductUpdate>
    </modules>
    <global>
        <events>
            <catalog_product_save_after>
                <observers>
                    <smashingmagazine_logproductupdate>
                          <class>smashingmagazine_logproductupdate/observer</class>
                          <method>logUpdate</method>
                        <type>singleton</type>
                    </smashingmagazine_logproductupdate >
                </observers>
            </catalog_product_save_after>
        </events>
    </global>
</config>

/ * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * *** /

这是观察者

<?php
/**
 * Our class name should follow the directory structure of
 * our Observer.php model, starting from the namespace,
 * replacing directory separators with underscores.
 * i.e. app/code/local/SmashingMagazine/
 *                     LogProductUpdate/Model/Observer.php
 */
class SmashingMagazine_LogProductUpdate_Model_Observer extends Varien_Event_Observer
{
    /**
     * Magento passes a Varien_Event_Observer object as
     * the first parameter of dispatched events.
     */
    public function logUpdate(Varien_Event_Observer $observer)
    {
        // Retrieve the product being updated from the event observer
        $product = $observer->getEvent()->getProduct();

        // Write a new line to var/log/product-updates.log
        $name = $product->getName();
        $sku = $product->getSku();
        Mage::log(
            "{$name} ({$sku}) updated",
            null, 
            'product-updates.log',
            true
        );
    }
}

2 个答案:

答案 0 :(得分:1)

<global>标记

内的config.xml中添加此内容
<models>
    <smashingmagazine_logproductupdate>
        <class>SmashingMagazine_LogProductUpdate_Model</class>
    </smashingmagazine_logproductupdate>
</models>

并清除缓存

答案 1 :(得分:1)

在Magento中创建config xml时需要注意一些事项。

  1. 始终使用<Namesapce_Modulename>而不是<NameSpace_ModuleName>,因为当您使用'namesapce/modulename'创建对象时它将无效,因为Magento尝试查找类似Namespace_Modulename_Model_Class而不是{{{ 1}}。

  2. 在您的情况下,要么正确更改名称空间和Moduel名称,要么使用以下config.xml

    NameSpace_ModuleName_Model_Class

  3. 并相应更改文件夹名称。

相关问题