If I do see this function in my controller - how does Magento knows which layout (and templates) it needs to load/show?

public function upsellAction()

Finding the layout of your module

In your module etc/config.xml you can find the following:

        <module module="Vendor_Module">

If this node is located under the <frontend> node you'll will that file under app/design/frontend/base/default/layout/path/to.xml. In case this node is under the <adminhtml> node it will be under app/design/adminhtml/default/default/layout/path/to.xml

Finding the right handle for this action method

First, you need to find out the route name of your module.

It's located under your module folder in the etc/config.xml

If you're dealing with a frontend controller it would be under the <frontend> node:


In the example above, your frontname is customfrontname.

In case of a backend controller the frontend will always be adminhtml if your store is patched.

Now, you need to find your controller name, it's not hard it's the start of your controller file.

Example if your controller is called CustomController.php it will be custom.

Finally, the last part is the start of your method name.

In your case as your method is called upsellAction it will be upsell.

To summarize, in my example, your layout handle will be <customfrontname_custom_upsell> in case of a frontend controller and <adminhtml_custom_upsell> in case of a backend controller.

Now, you just need to open the layout file found in the first part and look what's inside those layout handles nodes.

| improve this answer | |

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.