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"???
The cache will be initialized before module configurations (config.xml) are loaded. The cache-Model was instanciated with Mage::getModel, which caches the modelnames in the registry. So all later tries to get the custom cache-model will also fail.
Solution: put this rewrite statement in the etc/local.xml. This is a bit dirty because the local.xml should only hold module independent stuff. But this is better than copying core files to local.
I had the same question, but my solution is a little bit different to yours ;-)
Magento will load the XML file from /app/etc/*.xml (this files will not be cached) before everything else in magento. So i created my own file here "cache.xml" and the content is
<?xml version="1.0"?>
<config>
    <global>
        <models>          
            <core>
                <rewrite>
                    <cache>MyCompany_MyModule_Model_Core_Cache</cache>
                </rewrite>
            </core>
        </models>
    </global>
</config>
works perfect in 1.6,1.7 and 1.8
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With