Loading presentation...

Present Remotely

Send the link below via email or IM

Copy

Present to your audience

Start remote presentation

  • Invited audience members will follow you as you navigate and present
  • People invited to a presentation do not need a Prezi account
  • This link expires 10 minutes after you close the presentation
  • A maximum of 30 users can follow your presentation
  • Learn more about this feature in our knowledge base article

Do you really want to delete this prezi?

Neither you, nor the coeditors you shared it with will be able to recover it again.

DeleteCancel

Magento training -EAV part 2

No description
by

Diana Botean

on 8 May 2017

Comments (0)

Please log in to add your comment.

Report abuse

Transcript of Magento training -EAV part 2

EAV design wrap-up
- EAV generalizes row modeling by saving all entity attributes affected by sparseness or volatility in one or several tables, which store data in attribute-value pairs. 

-
vertical design
instead of horizontal (unlimited number of attributes)

- entity attributes vary significantly in terms of
data type
.

-
the number of possible entity types is huge,
and entity types have individual sets of attributes; even if the number of attributes in every set is relatively small.

-
some attributes are common to all
(or at least some) entity types, while
other are individual and sparse
. (hybrid approach - static attributes VS EAV attributes)
Attribute metadata
- besides
eav_attribute
table, Magento uses other tables alse to store attribute specific metadata:
catalog_eav_attribute
and
customer_eav_attribute

- catalog_eav_attribute
stores catalog entities attributes' metadata

-
customer_eav_attribute
stores customer entity attribute's metadata

Mage_Eav
- is the
core module of Magento EAV

- is the
layer
between the EAV data structures and the shop domain models (product, category, etc)

- it contains classes that can access and manipulate data for every EAV entity in Magento

- the
Mage_Eav_Model_Entity_Setup
class will provide basic functions required to install an update EAV entity types and attributes via Magento install scripts

-
Mage_Catalog_Model_Resource_Setup
and 
Mage_Customer_Model_Resource_Setup
derive from
Mage_Eav_Model_Entity_Setup
and are used to install and configure EAV metadata for the
Mage_Catalog
and
Mage_Customer
modules

-
if you want to install your own entity type or add an attribute to existing ones,
use one of these classes as setup resource or write your own child class

Magento training - EAV part 2
Roadmap
Magento architecture, module structure
Request flow
Rendering
Working with DB in Magento
Entity-Attribute-Value (EAV) Model
Catalog
Customers
Sales
Checkout
Adminhtml
frontend_input_renderer
- custom rendering blocks
is_global
- scope manipulation
is_visible
- search results, definition of configurable products
is_searchable
- determines if the attribute's values can be used when searching products
is_filterable
- used in layered navigation (LN) or not
is_comparable
- used for products comparison
is_visible_on_front
- a bit confusing, defines if the attribute is via XmlConnect, but it doesn't affect the attributes visibility on frontend
is_html_allowed_on_front
- attribute values are stripped of HTML tags if this property and '
is_wysiwyg_enabled
' are set to false, otherwise, the HTML tag will be preserved
is_used_for_price_rules
- specifies if the attribute is used for catalog price rules
is_filterable_in_search
- if it appears in search LN
used_in_product_listing
- available to frontend in category products, search results, uppsell crossell products and many others
used_for_sort_by
- listing sorting conditions
is_configurable
- indicates if the attribute can be used to create 'superproducts' - configurable products
apply_to
- specifies which product types will have this attribute
is_visible_in_advanced_search
- if it will be displayed or not in the advanced search form
position
- position in LN
i
s_wysiwyg_enabled
- allows adding a WYSIWYG JavaScript editor to the textarea input field in the backend
is_used_for_promo_rules
- if it's used to create promotion rules
- the table eav_entity_type lists 8 entity types in Magento, but only 4 are implemented as EAV(
product
,
category
,
customer
and
customer address)

- for all these types, Magento offers resource models that connect them to their data in the EAV structure of db tables

- the other 4 entities (
sales

entities
) have their resource models that connect them to flat tables to increase performance
(they were at some point EAV also, you will also find classes defined for EAV manipulation, but only for backwards compatibility)
EAV entities vs Non-EAV entities
What kind of metadata?
check
Magento admin -> Catalog -> Attributes
catalog_eav_attribute


Catalog entities attribute metadata
Loading a catalog model and its attributes
- as you probably guessed, you need a resource model to load data into an instance of
Mage_Catalog_Model_Category
or
Mage_Catalog_Model_Product
.
- the resource model extends the
Mage_Catalog_Model_Resource_Abstract
class and uses its
load()
method which calls
Mage_Eav_Model_Entity_Abstract::load()
that does this:

1. loads the data row from the entity table for the given object

2. calls
Mage_Eav_Model_Entity_Abstract::loadAllAttributes()
and retrieves the attribute instances for the static attributes and the EAV attributes filtered by attribute set

3. calls
Mage_Eav_Model_Entity_Abstract::_loadModelAttributes($object)
which loads data into the object's attribute

4. calls
Mage_Eav_Model_Entity_Abstract::_afterLoad()
which calls
Mage_Eav_Model_Entity_Abstract::walkAttributes()
method that loops through all the preloaded attribute models and uses their backend models to perform the data manipulation required after the data is loaded into an object

5. if you load a product object, then in the final stage, it checks if the product has options and if true, then it loads them
Attributes and install scripts
check
https://makandracards.com/magento/6721-product-attribute-addition
Mage_Eav_Model_Entity_Setup
<add>/<update>/<remove>EntityType(<params>)
<add>/<update>/<remove>AttributeSet(<params>)
<add>/<update>/<remove>AttributeGroup(<params>)
_prepareValues($atr)
<add>/<update>/<remove>Attribute(<params>)
getAttributeId()
addAttributeToSet()
addAttributeToGroup()
...
$collection = Mage::getModel('catalog/product')->getCollection();
$collection->addAttributeToSelect('name');
$collection->addAttributeToSelect('ean');
$collection->addAttributeToFilter('sku', '678678');
Product collections - attribute filtering
addFieldToFilter()
and
addFieldToSelect()
- used for Non-EAV collections
addAttributeToFilter()
and
addAttributeToSelect()
- used for EAV collections
Mage_Eav_Model_Entity_Collection_Abstract
Full transcript