2

When I override the Mage_Catalog_Model_Layer I get this error:

Mage registry key "_singleton/catalog/layer" already exists

How to debug this?

2
  • How did you over ride? – TBI Infotech Jun 7 '14 at 8:49
  • in what purpose you're overriding it? – Mohamed23gharbi Jun 7 '14 at 12:49
1

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.

0

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 !

Not the answer you're looking for? Browse other questions tagged or ask your own question.