我遵循了一个教程,但我的观察者没有捕捉到事件。我知道事件正在触发,因为我正在记录它们。我在我的代码中找不到错误。
/local/Package/MODULE/etc/config.xml
<config>
<modules>
<Package_MODULE>
<version>0.1.0</version>
</Package_MODULE>
</modules>
<global>
<models>
<module>
<class>Package_MODULE_Model</class>
</module>
</models>
<events>
<catalog_product_gallery_upload_image_after>
<observers>
<module_model_upload>
<type>model</type>
<class>module/observer</class>
<method>printTestMessage</method>
</module_model_upload>
</observers>
</catalog_product_gallery_upload_image_after>
</events>
</global>
</config>
/local/Package/MODULE/Model/Observer.php
<?php
class Package_MODULE_Model_Observer{
public function printTestMessage(Varien_Event_Observer $observer){
Mage::log("TESTING ", null, 'events.log'); //<--same log statement I'm using to test the events firing
}
}
/etc/modules/Package_MODULE.xml
<config>
<modules>
<Package_MODULE>
<active>true</active>
<codePool>local</codePool>
</Package_MODULE>
</modules>
</config>
EDIT2:此错误出现在 system.log 中:
2013-02-14T17:10:21+00:00 ERR (3): Notice: Uninitialized string offset: 3 in /opt/bitnami/apps/magento/htdocs/includes/src/Varien_File_Uploader.php on line 538
2013-02-14T17:10:21+00:00 ERR (3): Warning: include(/opt/bitnami/apps/magento/htdocs/includes/src/Package_MODULE_Model_Observer.php): failed to open stream: No such file or directory in /opt/bitnami/apps/magento/htdocs/includes/src/Varien_Autoload.php on line 93
2013-02-14T17:10:21+00:00 ERR (3): Warning: include(): Failed opening '/opt/bitnami/apps/magento/htdocs/includes/src/Package_MODULE_Model_Observer.php' for inclusion (include_path='/opt/bitnami/apps/magento/htdocs/includes/src:.:/opt/bitnami/php/lib/php') in /opt/bitnami/apps/magento/htdocs/includes/src/Varien_Autoload.php on line 93