What does backend type static mean in Magento?
来源:互联网 发布:阿里云栖大会苏州 编辑:程序博客网 时间:2024/06/06 19:23
What does backend type static mean in Magento?
Abouta year ago, I noticed some category or product attributes, for example,sku, path, etc., were given backend type “static” in classMage_Catalog_Model_Resource_Eav_Mysql4_Setup. But I failed to find outwhat static meant here, or I did not know what the difference wasbetween static and datetime/decimal/int/text/varchar. All I knew atthat time was if I gave my user defined attribute a “static” type, theattribute values were stored in _varchar table.
Recently, I dived deeper into Magento EAV module. Now I can answer my question.
An entity can have some “static” attributes, whose values are storedin entity main table. Take sku for example, sku values are stored incatalog_product_entity table. Although sku is varchar type, its valuesare not stored in catalog_product_entity_varchar. Magento does notlookup catalog_product_entity_varchar for sku values because ineav_attribute table, sku backend type is defined as “static”.
It also explains why I can get sku values without add it to select, but I can not do the same with non static attributes.
1
$collection
= Mage::getModel(
'catalog/product'
)->getCollection();
2
echo
$collection
->getFirstItem()->getSku();
It will output the sku.
1
$collection
= Mage::getModel(
'catalog/product'
)->getCollection();
2
echo
$collection
->getFirstItem()->getName();
It will not output the name.
1
$collection
= Mage::getModel(
'catalog/product'
)->getCollection()->addAttributeToSelect(
'name'
);
2
echo
$collection
->getFirstItem()->getName();
Calling addAttributeToSelect is a must to retrieve non static attribute values.
For user defined attributes of existing entity, if I do not changethe structure of main entity table, even I specify backend as “static”in entity setup class, Magento has nowhere to store their values to butfallback to _varchar table.
- What does backend type static mean in Magento?
- What does (Aborted) mean in HttpWatch?
- In Javascript, what does this underscore mean?
- What does ^M character mean in Vim?
- What does “%.*s” mean in printf?
- What does Using filesort mean in MySQL?
- What does it mean to write `static void * ptr = &ptr` in objective-c?
- Constraints on Type Parameters (what does where T : class mean)
- What does "Error: L6248E: cannot have address type relocation" mean?
- what does “static int function(…) __acquires(..) __releases(…){” mean?
- what does boinc mean?
- what does "ERP" mean
- What does "V"mean
- What does "Vanilla" mean ?
- Discussion1: What does mandatory/required variable in a query mean?
- What does the first letter "c" mean in "calloc"?
- What does "size" in int(size) of MySQL mean?
- what does mean "Units" in apple app sales report?
- Vmware View 4.5 体验
- Const,Const函数,Const变量,函数后面的Const (zz)
- win7下nginx+php安装
- Controller override and request rewrite in Magento
- Android 全局数据的应用
- What does backend type static mean in Magento?
- Winsock - CreateIoCompletionPort
- c++ 虚函数 工作机制 原理( virtual function )
- Is appending block by handle possible in Magento layout xml?
- 正式开始写打怪程序
- embedded matlab subset中的帧信号(frame-based signals)
- 操作系统总结之进程
- 把COM0变成可以用的普通串口
- custom tree node