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

Writing an adapter model


A new shipping module is initialized in the previous recipe. What we did in the previous recipe was a preparation to continue with the business part we will see in this recipe. We will add a model with the business logic for the shipping method. The model is called an adapter class because Magento requires an adapter class for each shipping method. This class will extend the Mage_Shipping_Model_Carrier_Abstract class.

This class will be used for the following things:

  • Make the shipping method available

  • Calculate the shipping costs

  • Set the title in the frontend of the shipping methods

How to do it...

Perform the following steps to create the adapter class for the shipping method:

  1. Create the folder app/code/local/Packt/Shipme/Model/Carrier if it doesn't already exist.

  2. In this folder, create a file named Shipme.php and add the following content to it:

    <?php
    class Packt_Shipme_Model_Carrier_Shipme 
      extends Mage_Shipping_Model_Carrier_Abstract
      implements Mage_Shipping_Model_Carrier_Interface...