The method getAttributeText
looks like this:
public function getAttributeText($attributeCode)
{
return $this->getResource()
->getAttribute($attributeCode)
->getSource()
->getOptionText($this->getData($attributeCode));
}
Notice the last 2 lines.
They mean that the method calls getOptionText
from the source model class.
I see that your attribute has a custom source model npm_recurrex/package_source
. Make sure that model has the method getOptionText
or it's parent class has it and returns what your need.
[EDIT]
Your getOptionText
is wrong.
It would work if the attribute would be of type select
.
But it doesn't work for multiselects.
Here is a scenario. Actually I'm using your scenario.
$_product->getData('package')
returns 1,2
.
And I assume your options are something like this:
$options[] => array('value' => 1, 'label'=>'Option 1');
$options[] => array('value' => 2, 'label'=>'Option 2');
$options[] => array('value' => 3, 'label'=>'Option 3');
$options[] => array('value' => 4, 'label'=>'Option 4');
In this case, your method receives as parameter 1,2
and you check if there is an element in $options
with value = 1,2
. and there isn't.
Try to make your method look like this:
public function getOptionText($value)
{
$options = $this->getAllOptions(false);
$optionsByValue = array();
foreach ($options as $item) {
$optionsByValue[$item['value']] = $item['label'];
}
$values = explode(',', $value);
$returnValue = array();
foreach ($values as $_value) {
if (isset($optionsByValue[$_value])) {
$returnValue[] = $optionsByValue[$_value];
}
}
return implode(', ', $returnValue);
}
Untested code so look out for typos.