Book Image

Magento PHP Developer's Guide

By : Allan MacGregor
Book Image

Magento PHP Developer's Guide

By: Allan MacGregor

Overview of this book

<p>Magento has completely reshaped the face of e-commerce since its launch in 2008. Its revolutionary focus on object oriented and EAV design patterns has allowed it to become the preferred tool for developers and retailers alike.</p> <p>"Magento PHP Developer’s Guide" is a complete reference to Magento, allowing developers to understand its fundamental concepts, and get them developing and testing Magento code.</p> <p>The book starts by building the reader’s knowledge of Magento, providing them with the information, techniques, and tools that they require to start their first Magento development.</p> <p>After building this knowledge, the book will then look at more advanced topics: how to test your code, how to extend the frontend and backend, and deploying and distributing custom modules.</p> <p>"Magento PHP Developer’s Guide" will help you navigate your way around your first Magento developments, helping you to avoid all of the most common headaches new developers face when first getting started.</p>
Table of Contents (16 chapters)
Magento PHP Developer's Guide
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Models and saving data


Before jumping straight into creating our models, we need to define clearly what type of models we are going to build and how many. So let's review our example scenario. For our gift registry, it appears that we will need two different models:

  • Registry Model: This model is used to store the gift registry information, such as gift registry type, address, and recipient information

  • Registry Item: This model is used to store the information of each of the gift registry items (quantity requested, quantity bought, product_id)

Although this approach is correct, it does not meet all the requirements of our example scenario. By having all the registry information stored into a single table, we cannot add more registry types without modifying the code.

So, in this case, we will want to break down our data into multiple tables:

  • Registry Entity: This table is used to store the gift registry and event information

  • Registry Type: By storing the gift registry type into a separate table...