2
我有一个覆盖Magento核心类的小问题:Core/Rule/Model/Rule.php。 我想我正在做的一切,但代码只是不工作(没有改变)。Magento规则模型覆盖
我的[名称空间] /Rule/etc/config.xml:
<?xml version="1.0"?>
<config>
<modules>
<[namespace]_Rule>
<version>0.1.0</version>
</[namespace]_Rule>
</modules>
<global>
<models>
<rule>
<rewrite>
<rule>[namespace]_Rule_Model_Rule</rule>
</rewrite>
</rule>
</models>
</global>
</config>
我的[名称空间] /Rule/Model/Rule.php:
class [namespace]_Rule_Model_Rule extends Mage_Rule_Model_Rule
{
protected function _beforeSave()
{
if ($this->getConditions()) {
$this->setConditionsSerialized(serialize($this->getConditions()->asArray()));
$this->unsConditions();
}
if ($this->getActions()) {
$this->setActionsSerialized(serialize($this->getActions()->asArray()));
$this->unsActions();
}
$this->_prepareWebsiteIds();
if (is_array($this->getCustomerGroupIds())) {
$this->setCustomerGroupIds(join(',', $this->getCustomerGroupIds()));
}
parent::_beforeSave();
}
我的应用程序的/ etc/[命名空间] _All.xml:
<?xml version="1.0"?>
<config>
<modules>
<[namespace]_Rule>
<active>true</active>
<codePool>local</codePool>
</[namespace]_Rule>
</modules>
</config>
我真的很感谢一些帮助。
我想重写SalesRule模型,但它没有被覆盖。我已经发布了一个关于这个问题。你能帮忙吗? http://stackoverflow.com/questions/7688803/magento-unable-to-override-sales-rule – 2011-10-08 09:57:45