Hi,
I have some problem with multi-select list, I just want to get ONLY selected values from admin panel ( product attributes multi-select list ), the example output is on this URL -> http://frakta.he-hosting.de/silence-4-nm-60.html
This is Product attribute multi-select code from Magento admin panel.
<select>
<option selected="selected" value="17">230V</option>
<option selected="selected" value="18">24VAC</option>
<option value="20">24VAC/DC</option>
<option value="19">24VDC</option>
</select>
Here is also my code from view.phtml file (product view)
function getSelectAttributeValues($attrCode) {
$attributeCode = $attrCode;
// build and filter the product collection
$products = Mage::getResourceModel('catalog/product_collection')
->addAttributeToFilter($attributeCode, array('notnull' => true))
->addAttributeToFilter($attributeCode, array('neq' => ''))
->addAttributeToSelect($attributeCode);
// ### it returns all values from multi-select list, but it should return only selected
$usedAttributeValues = array_unique($products->getColumnValues($attributeCode));
// fetch the attribute model
$attributeModel = Mage::getSingleton('eav/config')->getAttribute('catalog_product', $attributeCode);
// map the option id's to option labels
$usedAttributeValues = $attributeModel->getSource()->getOptionText(
implode(',', $usedAttributeValues)
);
if (is_array($usedAttributeValues)) {
return implode(', ', $usedAttributeValues);
} else {
return $usedAttributeValues;
}
}
Please help me, I'll be gratefull for any advice