- Magento PHP Developer's Guide(Second Edition)
- Allan MacGregor
- 338字
- 2021-07-16 13:16:04
Chapter 2. ORM and Data Collections
Collections and models are the bread and butter of everyday Magento development. In this chapter, we will introduce the reader to the Magento ORM system, and we will learn how to work with data collections and the EAV system properly. As most modern systems, Magento implements an object-relational mapping (ORM) system.
Object-relational mapping (ORM, O/RM, and O/R mapping) in computer software is a programming technique for converting data between incompatible type systems in object-oriented programming languages. This creates, in effect, a "virtual object database" that can be used from within the programming language.
In this chapter, we will cover the following topics:
- Magento Models
- Anatomy of a Magento Data Model
- EAV and EAV models
- Working with Direct SQL queries
We will also be working with several snippets of code to provide an easy framework to experiment and play around with Magento.
Note
The interactive examples in this chapter assume you are working either with the default Magento installation inside the VagrantBox or a Magento installation with sample data.
For this purpose, I have created the Magento IMC (Interactive Magento Console), which is a shell script specially created for this book and inspired by Ruby's IRB (Interactive Ruby Console). To get started, follow these steps:
- The first thing we will need to do is install the IMC to download the source files from https://github.com/amacgregor/mdg_imc and extract them under your Magento test installation. The IMC is a simple Magento shell script that will allow to test our code in real time.
- Once you extract the script, log into the shell of your VirtualBox.
- Next, we will need to navigate to our Magento root folder. If you are using the default vagrant box and installation provided, the root folder is located under
/srv/www/ce1720/public_html
. We navigate to it by running this command:$ cd /srv/www/ce1720/public_html
- Finally, we can start the IMC by running the following command:
$ php shell/imc.php
- If everything is installed successfully, we will see a new line starting with
magento >
.
- JavaScript前端開發(fā)模塊化教程
- Java異步編程實(shí)戰(zhàn)
- Java面向?qū)ο笏枷肱c程序設(shè)計(jì)
- Learning Chef
- Hadoop+Spark大數(shù)據(jù)分析實(shí)戰(zhàn)
- Learning Zurb Foundation
- SQL Server實(shí)用教程(SQL Server 2008版)
- Raspberry Pi Robotic Projects(Third Edition)
- Java EE架構(gòu)設(shè)計(jì)與開發(fā)實(shí)踐
- DevOps 精要:業(yè)務(wù)視角
- 嵌入式C編程實(shí)戰(zhàn)
- Python數(shù)據(jù)預(yù)處理技術(shù)與實(shí)踐
- Scratch少兒編程高手的7個(gè)好習(xí)慣
- C#編程魔法書
- HTML+CSS+JavaScript前端開發(fā)(慕課版)