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

Preface

Magento is one of the most popular e-commerce platforms on the market because it is free, stable, and offers a lot of functionalities. A lot of e-commerce websites are built with Magento. Developing in Magento is not as easy as you would expect. When you want to start with Magento, a good guide that shows you the best practices will be very helpful while learning Magento development, and that is what this book has set out to do.

With Magento 1.8 Development Cookbook, we will discover all the topics that will help you become a good Magento developer, and then we start with the basics and end with more advanced topics towards the end of this book. This will be a good guideline that explains every step or action that you have to take to complete the recipes of this book.

We will start this book with the creation of a good development environment using the right tools. We will create a web server where we will put a Magento installation with sample products in it. We will create a custom theme to change the look and feel of the webshop. The focus of this book will be the development part. We will create a custom module that follows the best practices of Magento. We will customize this module with a lot of common features that are used in Magento projects, such as extra controller pages, database integrations, custom shipping methods, and extra backend interfaces. At the end of the book, we will see how we can improve the performance of our Magento installation. Finally, we will see some debugging techniques such as xDebug and create a unit test with PHPUnit.

What this book covers

Chapter 1, Getting Started with Magento, gives you an introduction and shows you how to create a development environment using the right tools, how to install Magento, and how to work with the code in a version control system.

Chapter 2, Theming, explains what you can do to customize the look and feel of your shop.

Chapter 3, Working with Products, gives you more information about the possibilities of showing the products in your shop and customizing the product pages with a Facebook like button.

Chapter 4, Creating a Module, describes how to create a basic Magento module, how to extend that module with configurations for a custom page, translations, blocks, and how to rewrite existing classes.

Chapter 5, Database Concepts, shows you how Magento works with database connections, how the tables are linked to Magento entities, and how the EAV system works. It also shows you how to create a Master/Slave setup.

Chapter 6, Databases and Modules, teaches you how to extend a Magento module with a database interaction by creating an install script that installs a database table and entity that will interact with this database table.

Chapter 7, Magento Backend, covers the topics that you should know when integrating your module with the Magento backend, such as adding extra configuration pages, creating overview pages, and extending the admin menu.

Chapter 8, Event Handlers and Cronjobs, describes how the Event-driven Architecture is implemented in Magento and how you can use this in a module. Later in this chapter, you will learn how to create cronjobs in a module and how to test them.

Chapter 9, Creating a Shipping Module, shows you how to create a custom module with the configurations required for a new shipping method.

Chapter 10, Creating a Product Slider Widget, explains how to create a module with a custom widget, how to build the backend interface, and how to provide a good UI in the frontend of that widget.

Chapter 11, Performance Optimization, describes how to benchmark your site to know the limits and improve its performance using different techniques such as web server optimization and caching systems (APC and Memcached).

Chapter 12, Debugging and Unit Testing, shows you how to use the PHP debugger xDebug, how to use FirePHP in Magento, and how to create a simple unit test with PHPUnit.

What you need for this book

  • Magento 1.8 source code

  • Ubuntu Version 13.10 or higher

  • Apache2

  • PHP Version 5.3 or higher

  • MySQL Server 5

  • NetBeans IDE

  • phpMyAdmin

  • Wiz command-line tool

  • Firebug (add-on for Firefox)

  • FirePHP (add-on for Firefox)

  • xDebug

  • PHPUnit

  • A standard web browser

  • Siege (a benchmarking tool)

  • ApacheBench (another benchmarking tool)

  • YSlow (add-on for Firefox)

  • Git SCM

  • jQuery

  • carouFredSel (a jQuery library to create a jQuery carousel)

Who this book is for

If you know something about programming in PHP and want to start with Magento development, this book has something for you. Knowledge of Magento is not required to start with the recipes of this book. Basic knowledge of PHP and web development is required. This book starts with the fundamentals of Magento development and ends with more advanced topics. Even if you know something about Magento development yet you need a good guide, this book has something for you.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, pathnames, dummy URLs and user inputs are shown as follows: "The widget.xml file is used to define widgets in the Magento installation."

A block of code is set as follows:

<category_id>
    <label>Category ID</label>
    <type>text</type>
    <required>1</required>
    <sort_order>20</sort_order>
    <visible>1</visible>
</category_id>

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

<category_id>
    <label>Category ID</label>
    <type>text</type>
    <required>1</required>
    <sort_order>20</sort_order>
    <visible>1</visible>
</category_id>

Any command-line input or output is written as follows:

sudo apt-get install apache2

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes, for example, appear in the text like this: "Click on Finish and your NetBeans project is ready."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title via the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.