We always require the attribute data via attribute code. Below is the code to get the product attribute data from the attribute code. It can used to get the attribute data from the code, without always trying to load the attribute model.
public function getAttribute($code) {
$this->getAttributes();
if (isset($this->_attributes[$code])) {
return $this->_attributes[$code];
}
return null;
}
public function getAttributes() {
if (is_null($this->_attributes)) {
$this->_attributes = Mage::getResourceSingleton("catalog/product")
->loadAllAttributes()
->getAttributesByCode();
}
return $this->_attributes;
}
Comments
Post a Comment