Get custom attribute from product in Magento 1.9

Just remove the underscore:

$strProdSkuSup = $product->getSkuSupplier();  
$strProdSkuSup = $product->getData('sku_supplier'); //alternative 

Magento translates snake_case into camelCase when you want to use the magic getters; ie. an attribute with the attribute code cool_custom_attribute would translate into coolCustomAttribute, i.e. $product->getCoolCustomAttribute().

Edit:

You might need to load a product model as sometimes I've experienced that not all custom attributes are attached when you pull it out of a collection (intended for performance reasons I guess). Something like:

$_product = Mage::getModel('catalog/product')->load($product->getId());
$strProdSkuSup = $_product->getSkuSupplier();  

Also, did you know that there's a dedicated StackExchange site for Magento?


Use this

$strProdSkuSup = $product->getSkuSupplier();

Instead of

$strProdSkuSup = $product->getSku_Supplier(); 

Tags:

Php

Magento