Book Image

Magento PHP Developer????s Guide, 2nd Edition

By : Allan MacGregor
Book Image

Magento PHP Developer????s Guide, 2nd Edition

By: Allan MacGregor

Overview of this book

Table of Contents (16 chapters)
Magento PHP Developer's Guide Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Models and saving data


Before jumping straight to 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, which are as follows:

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

  • Registry item: This is used to store the information of each of the gift registry items (for example, quantity requested, quantity bought, and 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 in a single table, we cannot add more registry types without modifying the code.

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

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

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