/** * 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]; }
/** * Render attribute row and return HTML * * @param Mage_Eav_Model_Attribute $attribute * @return string */ public function getAttributeHtml(Mage_Eav_Model_Attribute $attribute) { $showOnGuest = TRUE; $setup = new Mage_Eav_Model_Entity_Setup('core_setup'); $entityTypeId = $setup->getEntityTypeId('customer'); if ($attribute->getEntityTypeId() == $entityTypeId) { $collection = Mage::getModel('customerattribute/customerattribute')->getCollection()->addFieldToFilter('attribute_id', $attribute->getAttributeId())->getFirstItem(); if ($collection->getShowOnCheckoutRegisterGuest() == 0) { $showOnGuest = FALSE; } } $type = $attribute->getFrontendInput(); $block = $this->getRenderer($type); if ($block) { $block->setAttributeObject($attribute)->setEntity($this->getEntity())->setFieldIdFormat($this->_fieldIdFormat)->setFieldNameFormat($this->_fieldNameFormat)->setShowOnGuest($showOnGuest); return $block->toHtml(); } return false; }