When I override the Mage_Catalog_Model_Layer I get this error:
Mage registry key "_singleton/catalog/layer" already exists
How to debug this?
When I override the Mage_Catalog_Model_Layer I get this error:
Mage registry key "_singleton/catalog/layer" already exists
How to debug this?
To rewrite this model you will need the following.
Rewrite in your config.xml
<models>
<your_module>
<class>Your_Module_Model</class>
</your_module>
<catalog>
<rewrite>
<layer>Your_Module_Model_Catalog_Layer</layer>
</rewrite>
</catalog>
</models>
Extend original class
<?php
class Your_Module_Model_Catalog_Layer extends Mage_Catalog_Model_Layer{}
To test that this rewrite works you could simply create a __construct
function in your new class, log that you are in your new class and call the parent::__construct
. This should help you debug if your rewrite is actually being picked up.
Then you can extend the layer class with whatever functionality you require for purposes.
Have you overriden the block like the way it is mensionned here? http://www.pierrefay.com/rewrite-model-magento-tutorial-howto-101
Because to override you should do two steps:
1-extend the modelclass
2-Declare the rewrite in the config.xml
Just a remarque may be you need to rewrite the block(calling that model) and then create a new model extending the Mage_Catalog_Model_Layer. in that way your new block will use your custom model without need to override the model itself, it is a more sure and proper way !