最近在做magento二次开发,遇到个问题,即,我要针对商品的数据中的某些数据做二次处理。看了一下代码,发现在initProduct前有一个event事件:catalog_product_prepare_save,所以我想我只要覆盖这个方法就OK了。网上找了些资料,发现如果再绑定一个event则
最近在做magento二次开发,遇到个问题,即,我要针对商品的数据中的某些数据做二次处理。看了一下代码,发现在initProduct前有一个event事件:catalog_product_prepare_save,所以我想我只要覆盖这个方法就OK了。网上找了些资料,发现如果再绑定一个event则多个Event都会执行。于是,我就按照这个思路在config.xml里加入了events事件。
然后在Model下面加了Observer.php来监听事件。为了测试系统自有的event能够工作,我在系统默认的event里做了一下输出,发现确实有变化 了。所以证明我的思路还是正确的。当然,这也借鉴了网上的一些资料
config.xml里加入:
?? ?????? ?????????? ?????????????? ?????????????????? ????????????????????singleton?? ????????????????????Xxx_Web_Model_Observer?? ????????????????????prepareProductAuthor?? ?????????????????? ?????????????? ?????????? ?????? ??
本来我class想写成xxxx/observer的,但死活通不过,我不知道是我写错了。还是。。最后写成详细的类名才OK。(也可能是因为不在系统目录下,而在local目录下的原因吧?)
Observer就不写了。参考core/mage/bundle/model/observer.php即可(本来有大小写的,我忽略了)
原文地址:magento 中处理 catalog_product_prepare_save 行为, 感谢原作者分享。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft
