without any problems I'm able to rewrite a model.
But when it comes to rewrite a model that is used in backend/admin panel and I want that functionality also in the frontend but a little bit different then ... I got a problem.

In the config.xml I have to declare my new rewritten model in the "global" node.
Here it works.

I tried to write it in the node "frontend" but with no effect.

Isn't it possible to do that only for frontend?


You cannot rewrite models only for frontend, because models are area agnostic. They should not know if they are instantiated on frontend or not.
But you can do an quick and dirty thing and rewrite the model and n certain actions just check if you are on frontend or not.

Here is an example.

Let's say that in the original model there is a method called doSomething() and you want this to behave differently on frontend and backend.

In your model that overrides the original one make your method look like this:

public function doSomething()
    if (Mage::app()->getStore()->getId() == 0 ) {
        //if on backend
        return parent::doSomething();
    //your magic for frontend here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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