I have checked lot and tried many things, but I am still not getting the product multiselect selected values label on product view page.
I have product attribute called package which is multiselect, Code that create the product attribute
$this->addAttribute(
'catalog_product',
'package',
array(
'group' => 'Package',
'backend' => 'eav/entity_attribute_backend_array',
'frontend' => '',
'class' => '',
'default' => '',
'label' => 'Package',
'input' => 'multiselect',
'type' => 'text',
'source' => 'npm_recurrex/package_source',
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
'is_visible' => 1,
'required' => 0,
'searchable' => 0,
'filterable' => 0,
'unique' => 0,
'comparable' => 0,
'visible_on_front' => 0,
'user_defined' => 1,
)
);
this works fine, I am successfully saving the product. But in frontend product view page when I say
Mage::log(print_r($_product->getData('package'), true));
Its prints the result as 1,2 But I wanted to display option labels of multiselect not option id's. So I tried with this code
Mage::log(print_r($_product->getAttributeText('package'), true));
It prints nothing, just blank space :(.
I have checked this link but no use.
I am confused with this, Where I am wrong? and what is the wrong thing?
Can anybody explain me what is happening in my case?
my getOptionText Method
public function getOptionText($value)
{
$options = $this->getAllOptions(false);
foreach ($options as $item) {
if ($item['value'] == $value) {
return $item['label'];
}
}
return false;
}