Magento get list of all product attributes
Get list of all the product attributes defined in Magento. This will fetch you an array with all the attribute codes as a key AND all the attribute details including attribute code as a value. You can limit this array by just attribute code and attribute label as per your need. I will show you all the possible attribute information you can fetch defined for the product.
$attrib_data = array(); $allAttributeCodes = array(); | |
$attributes = Mage::getResourceModel('catalog/product_attribute_collection')->getItems(); | |
foreach ($attributes as $attribute){ | |
$attrib_data[$attribute->getAttributeCode()] = $attribute->getData(); | |
//$allAttributeCodes[] = $attribute->getAttributeCode(); | |
} |
Sample Output:
Array( | |
[color] => Array | |
( | |
[entity_type_id] => 10 | |
[attribute_code] => color | |
[attribute_model] => | |
[backend_model] => | |
[backend_type] => int | |
[backend_table] => | |
[frontend_model] => | |
[frontend_input] => select | |
[frontend_label] => Color | |
[frontend_class] => | |
[source_model] => | |
[is_required] => 0 | |
[is_user_defined] => 1 | |
[default_value] => | |
[is_unique] => 0 | |
[note] => | |
[attribute_id] => 272 | |
[frontend_input_renderer] => | |
[is_global] => 1 | |
[is_visible] => 1 | |
[is_searchable] => 1 | |
[is_filterable] => 1 | |
[is_comparable] => 1 | |
[is_visible_on_front] => 0 | |
[is_html_allowed_on_front] => 0 | |
[is_used_for_price_rules] => 1 | |
[is_filterable_in_search] => 1 | |
[used_in_product_listing] => 0 | |
[used_for_sort_by] => 0 | |
[is_configurable] => 1 | |
[apply_to] => simple | |
[is_visible_in_advanced_search] => 1 | |
[position] => 1 | |
[is_wysiwyg_enabled] => 0 | |
[is_used_for_promo_rules] => 1 | |
) | |
[other_attribute_code] => Array | |
( | |
.... | |
) | |
) |
Now you can easily access all the attribute information from the above array.
2 Comments
Leave a comment
Welcome to my Blog
Certifications
Honor
Recognition
Contributions
Categories
- Apache (2)
- ChatGPT (1)
- Domain name (2)
- eCommerce (2)
- htaccess (1)
- Humor (3)
- Instagram API (1)
- jQuery (4)
- JSON (1)
- Linux (10)
- Magento (142)
- Magento admin (58)
- Magento Certification (5)
- Magento error (13)
- Magento frontend (68)
- Magento Imagine (2)
- Magento Interview (5)
- Magento Master (2)
- Magento2 (10)
- Mobile (1)
- MySQL (7)
- OpenAI (1)
- OroCRM (2)
- Performance (2)
- PHP (8)
- Prototype JS (3)
- Security (4)
- Wordpress (3)
- XML (2)
Tag Cloud
500 internal server error admin answers attribute bug category checkbox checkout cookie customer difference domain name EAV error event extension interview invoice jquery linux magento magento2 magento admin magento error magento interview questions magento orm mysql observer order pinterest product products questions redirect register remove script session simplexml to array state status study guide tax url wordpress
Hi,
Thanks,
I really enjoy the blog.Much thanks again. Great.
Thank you for this post. I wasn’t able to view all my 72 attributes untill now.
Cheers