Book Image

Magento 1.8 Development Cookbook

By : Bart Delvaux, Nurul Ferdous
Book Image

Magento 1.8 Development Cookbook

By: Bart Delvaux, Nurul Ferdous

Overview of this book

<p>Magento is an open source e-commerce platform which has all the functionality to function from small to large online stores. Its architecture makes it possible to extend the functionalities with plugins where a lot of them are shared by the community. This is the reason why the platform is liked by developers and retailers.</p> <p>A practical developer guide packed with recipes that cover all the parts of Magento development. The recipes will start with the simple development exercises and get the more advanced as the book progresses. A good reference for every Magento developer!</p> <p>This book starts with the basics. The first thing is to create a test environment. Next, the architecture, tools, files and other basics are described to make you ready for the real work.</p> <p>The real work starts with the simple things like theming and catalog configuration. When you are familiar with this, we will move on to more complex features such as module and database development. When you have survived this, we will move on to the last part of making a shop ready for launch: performance optimization and testing. This book will guide you through all the development phases of Magento, covering the most common pitfalls through its recipes.</p>
Table of Contents (19 chapters)
Magento 1.8 Development Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Creating your own event


When we want to create our own event, we have to dispatch it with a custom name. In this recipe, we will learn how events are dispatched and what we can do with parameters that we will forward.

Getting ready

We will create our own event that is fired when a visitor opens the helloAction() function of the Packt_Helloworld module. In this recipe, we will build further on the Packt_Helloworld module that is created in Chapter 4, Creating a Module, Chapter 6, Databases and Modules, and Chapter 7, Magento Backend. If you want, you can install the start files.

How to do it...

The following steps describe how we can dispatch our own event.

  1. Open the IndexController of the Packt_Helloworld module. In this controller, there is a helloAction() function where we will work to dispatch the event.

  2. To dispatch an event, the Mage::dispatchEvent() function is used. When we change the code of the helloAction() function to the following code, we will dispatch an event called helloworld_register_visit...