Search code examples
classcachingmagentourl-rewriting

How to rewrite the magento core-cache-model (Mage_Core_Model_Cache)


I have to rewrite the core cache model. And this doesn't work. My first attempt to solve the problem was to try the rewrite with another model... In my config.xml I declared the following

<global>         
  <models>          
    <core>
      <rewrite>
        <**layout**>MyCompany_MyModule_Model_Core_Cache</**layout**>
      </rewrite>
    </core>
  </models>
  ....

and in my class I died in the consturctor.

This works perfectly! So my may in rewriting models is the right one.

But If I don't use the layout-node in the xml but using the cache-node instead this does not work.

So my attempt is the following and this is not working:

<global>         
  <models>          
    <core>
      <rewrite>
        <cache>MyCompany_MyModule_Model_Core_Cache</cache>
      </rewrite>
    </core>
  </models>
  ....

My question now: is there a way to rewrite / overload the "cache-core-model"???


Solution

  • I'm also trying to do the same thing and i don't think it's possible. If you var_dump out $this->_xml->group->models in the method: getGroupedClassName (app/code/core/Mage/Core/Model/Config.php) you'll notice that your rewrite it's not yet available, hence why it's skipped.

    If you try to overwrite translate or layout: your_class_model you'll notice that the $this->_xml... dumps the initial core classes (with no rewrite) and you'll see your rewrite down the line well past the core/cache. So, it's probably being overridden but the class is already instantiated, set up and used; so it's really not going to fire anything.

    Hence i don't think it's possible to override the core/cache. You'll have to move it to the app/code/local. Pitty.