I have a very weird problem, I can get the product attribute value in local but when I go to the live server, I get an empty value. Magento version 1.6.2.
To get the attribute value, I use this code :
$product = Mage::getModel('catalog/product')->load($_item->getProductId());
$my_attribute = $product->getAttributeText('my_attribute');
PHP 5.3 and apache 2.2 on both local and live server
You can get customer custom_attribute value by, $customer = $CUSTOMER_OBJECT; // GET customer object $customer->getCustomAttribute('mobile')->getValue(); return will be your customer custom_attribute mobile value.
The “Add to Column Options” setting determines whether the attribute will be displayed in the product grid on your store's backend.
Magento 2 uses attributes to manage the information associated with products. An attribute is a property of a product, for example, the product color, the size, or the description. Some attributes are built into the system by default, and others can be created to address specific needs.
Try these things :
$attribute_option_id = Mage::getResourceModel('catalog/product')->getAttributeRawValue($productId, 'my_attribute', $storeId);
$product = Mage::getModel('catalog/product')
->setStoreId($storeId)
->setData('my_attribute', $attribute_option_id);
$text = $product->getAttributeText('my_attribute');
OR
$_id = $this->getProduct()->getId();
$_resource = Mage::getSingleton('catalog/product')->getResource();
$optionValue = $_resource->getAttributeRawValue($_id, [ATTRIBUTE_ID/ATTRIBUTE_CODE], Mage::app()->getStore());
echo $optionValue;
OR
$attribute_value = $product->getResource()->getAttribute($attribute_code)->getFrontend()->getValue($product);
Cheers :-)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With