/** * Update the frontend labels of the attribute * * @param Mage_Catalog_Model_Entity_Attribute $attribute Attribute to update * @param Aoe_AttributeConfigurator_Model_Config_Attribute $attributeConfig Attribute config * * @return void */ protected function _updateAttributeLabels($attribute, $attributeConfig) { $stores = Mage::app()->getStores(true); $storeLabels = []; $frontendLabel = $attribute->getAttributeCode(); foreach ($stores as $store) { /** @var Mage_Core_Model_Store $store */ $storeLocale = Mage::getStoreConfig('general/locale/code', $store); $storeLabel = $attributeConfig->getLabel($storeLocale); if (!$storeLabel) { continue; } $storeLabels[$store->getId()] = $storeLabel; if (0 == $store->getId()) { $frontendLabel = $storeLabel; } } $attribute->setFrontendLabel($frontendLabel)->setStoreLabels($storeLabels); $attribute->save(); }
/** * Check whether attribute reserved or not * * @param Mage_Catalog_Model_Entity_Attribute $attribute Attribute model object * @return boolean */ public function isReservedAttribute($attribute) { return $attribute->getIsUserDefined() && in_array($attribute->getAttributeCode(), $this->getReservedAttributes()); }
/** * Create the block filter for an attribute into the layer. * * @param Mage_Catalog_Model_Entity_Attribute $attribute Filtered attributes. * * @return Mage_Catalog_Block_Layer_Filter_Abstract */ protected function _addFilter($attribute) { $decimalValidationClasses = array('validate-number', 'validate-digits'); if ($attribute->getAttributeCode() == 'price') { $filterBlockName = $this->_priceFilterBlockName; } elseif ($attribute->getAttributeCode() == 'rating_filter') { $filterBlockName = $this->_ratingFilterBlockName; } elseif ($attribute->getSourceModel() == 'eav/entity_attribute_source_boolean') { $filterBlockName = $this->_booleanFilterBlockName; } elseif ($attribute->getBackendType() == 'decimal' || in_array($attribute->getFrontendClass(), $decimalValidationClasses)) { $filterBlockName = $this->_decimalFilterBlockName; } else { $filterBlockName = $this->_attributeFilterBlockName; } $filter = $this->getLayout()->createBlock($filterBlockName, $attribute->getAttributeCode() . '_filter')->setLayer($this->getLayer())->setAttributeModel($attribute)->init(); return $filter; }