In magento you can create as many custom attributes for your products as you want.Suppose you want to add or display brand color for every product on home, category or product page. So this is very easy to do with custom attributes.
If we were to create a new custom attribute called “brand_color” and the attribute was of a “Text Field” type, we could do something like the following at a product level to obtain its value.
<?php echo $_product->getBrandColor(); ?>
Get attribute collection
<?php $attribute = $_product->getResource()->getAttribute('my_attribute'); ?>
Get attribute type
<?php $attribute = $_product->getResource()->getAttribute('my_attribute')->getAttributeType(); ?>
Get attribute Label
<?php $attribute = $_product->getResource()->getAttribute('my_attribute')->getFrontendLabel(); ?>
Attribute is visible or not
<?php $attribute = $_product->getResource()->getAttribute('my_attribute')->getIsVisible(); ?>
Attribute is required
<?php $attribute = $_product->getResource()->getAttribute('my_attribute')->getIsRequired(); ?>
Get attribute value
<?php $attributeValue = Mage::getModel('catalog/product')->load($_product->getId())->getMyAttribute();?>
Get the multi-select attribute values
<?php $attributeId = Mage::getResourceModel('eav/entity_attribute')->getIdByCode('catalog_product','attribute_code_here'); $attribute = Mage::getModel('catalog/resource_eav_attribute')->load($attributeId); $attributeOptions = $attribute ->getSource()->getAllOptions(); ?>
Get specific attribute value
<?php $attributeValue = Mage::getModel('catalog/product') ->load($_product->getId()) ->getAttributeText('my_attribute'); ?>
Justwebdevelopment can also help you in...
Magento Development | PSD To Magento | Magento Theme Development | Magento Development Services
Magento Development | PSD To Magento | Magento Theme Development | Magento Development Services