/**
  * Return the indexed attribute value.
  *
  * @param Mage_Eav_Model_Attribute $attribute Attribute we want the value for.
  * @param mixed                    $value     Raw value
  * @param int                      $storeId   Store id
  *
  * @return mixed.
  */
 protected function _getAttributeValue($attribute, $value, $storeId)
 {
     if ($attribute->usesSource()) {
         if (!is_array($value)) {
             $value = explode(',', $value);
         }
         $value = array_filter($value);
         $value = array_values(array_unique($value));
         if ($attribute->getBackendType() == 'int') {
             $value = array_map('intval', $value);
         }
         if (count($value) == 1) {
             $value = current($value);
         }
     } else {
         if ($attribute->getBackendType() == 'decimal') {
             $value = floatval($value);
         } else {
             if ($attribute->getBackendType() == 'int') {
                 $value = intval($value);
             }
         }
     }
     return $value;
 }