コード例 #1
0
 /**
 
 
     /**
 * Return the text value for an atribute using source model.
 *
 * @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 _getOptionsText($attribute, $value, $storeId)
 {
     $attribute->setStoreId($storeId);
     if ($attribute->getSource()) {
         $value = $attribute->getSource()->getIndexOptionText($value);
     }
     return $value;
 }
コード例 #2
0
 /**
  * Load all options for an attribute using source.
  *
  * @param Mage_Eav_Model_Attribute $attribute Attribute we want the value for.
  * @param int                      $storeId   Store id.
  *
  * @return array
  */
 protected function _getAllOptionsText($attribute, $storeId)
 {
     $attributeId = $attribute->getAttributeId();
     if (!isset($this->_indexedOptionText[$attributeId]) || !isset($this->_indexedOptionText[$attributeId][$storeId])) {
         $options = array();
         if ($attribute->getSource()) {
             $storeIds = array(0, $storeId);
             foreach ($storeIds as $storeId) {
                 $attribute->setStoreId($storeId);
                 $allOptions = $attribute->getSource()->getAllOptions(false);
                 foreach ($allOptions as $key => $value) {
                     if (is_array($value) && isset($value['value'])) {
                         $options[$value['value']] = $value['label'];
                     } else {
                         $options[$key] = $value;
                     }
                 }
             }
         }
         $this->_indexedOptionText[$attributeId][$storeId] = $options;
     }
     return $this->_indexedOptionText[$attributeId][$storeId];
 }