0

Let's say we have a list of wrenches:

https://www.toolworld.com/hand-tools/wrenches?order=price

I'm trying to find the predispatch event handler for the Catalog's product list page so that I can sanitize the 'order' parameter's input before it is sent to the controller.

I'm new to magento and have been having trouble finding it.

Where is it?

0

Short answer: After some digging I found that there wasn't a predispatch handler already defined in my config.xml file for the page I cited (Catalog Category View) so I had to create one.

Longer answer: I consulted 'Phparchitect's Guide to E-Commerce Programming with Magento' which has a section that lists the syntax of predispatch events you can listen for, namely:

controller_action_predispatch

controller_action_predispatch_ModuleName

controller_action_predispatch_ModuleName_ControllerName_ActionName

I plugged in my module, controller, and action names (Catalog/Category/View) and created a new handle in config.xml, which also specified an Obserfer class and a method like so:

<controller_action_predispatch_catalog_category_view>
    <observers>
        <template>
            <class>Template_Catalog_Model_Observer</class>
            <method>predispatchCatalogCategoryView</method>
        </template>
    </observers>
</controller_action_predispatch_catalog_category_view>

Afterward, I navigated to the Observer class and created a new method with the method name specified above. Using my debug log I was able to detect this method being hit upon loading the page again.

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.