Posted by: james | August 3, 2009

How to get attribute in magento using getAttribute and getSource

in app/code/local/Form/Warrenty/Block/Form.php

public function getAttText($attributeCode)
{
$product = Mage::getModel(‘catalog/product’);

return $product->getResource()
->getAttribute($attributeCode)
->getSource()
->getAllOptions($this->getData($attributeCode));
}

in app/design/frontend/default/default/template/warrenty/form.phtml

<tr>
<td>Brand:</td>
<td height=”31″>
<select name=”brand” id=”brand”>
<?php foreach ($this->getAttText(‘manufacturer’) as $manufacturer): ?>
<option>
<?php echo $manufacturer[‘label’] ?>
</option>
<?php endforeach; ?>
</select></td>
</tr>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: