What does backend Type Static mean in magento?

Source: Internet
Author: User
What does backend Type Static mean in magento? Posted on
January 28,201 1

By
Fangcaoyuan owner

About
A year ago, I noticed some category or product attributes, for example,
SKU, path, Etc., were given backend type "static" in class
Mage_catalog_model_resource_eav_mysql4_setup. But I failed to find out
What static meant here, or I did not know what the difference was
Between static and datetime/decimal/INT/text/varchar. All I knew
That time was if I gave my user defined attribute a "static" type,
Attribute 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 stored
In Entity main table. Take SKU for example, SKU values are stored in
Catalog_product_entity table. Although SKU is varchar type, its values
Are not stored in catalog_product_entity_varchar. magento does not
Lookup catalog_product_entity_varchar for SKU values because in
Eav_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.

View Source
Print
?
1 $collection
= Mage::getModel(
'catalog/product'
)->getCollection();
2 echo
$collection
->getFirstItem()->getSku();

It will output the SKU.

View Source
Print
?
1 $collection
= Mage::getModel(
'catalog/product'
)->getCollection();
2 echo
$collection
->getFirstItem()->getName();

It will not output the name.

View Source
Print
?
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 change
The structure of main entity table, even I specify backend as "static"
In Entity setup class, magento has nowhere to store their values to
Fallback to _ varchar table.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.