tags:

views:

23

answers:

1

I've got a little problem overriding the Magento core class: Core/Role/Model/Role.php. I think I'm doing everything correctly, but the code just doesn't work (Nothing changes).

My [namespace]/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>

My [namespace]/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();
    }

My app/etc/[namespace]_All.xml:

<?xml version="1.0"?>
<config>
    <modules>
    <[namespace]_Rule>
           <active>true</active>
           <codePool>local</codePool>
       </[namespace]_Rule>

    </modules>
</config>

I would really appreciate some help.

A: 

I've managed to solve it by overriding SalesRule (Mage/SalesRule/Model/Rule) instead of Rule. You can only override the Rule module when you do it static (by creating a local/Mage/Rule/Model/Rule.php file).

M_F