/** * Define if attribute should be visible for passed user type * * @param Mage_Catalog_Model_Resource_Eav_Attribute $attribute * @param string $userType * @return bool */ protected function _isAttributeVisible(Mage_Catalog_Model_Resource_Eav_Attribute $attribute, $userType) { $isAttributeVisible = false; if ($userType == Mage_Api2_Model_Auth_User_Admin::USER_TYPE) { $isAttributeVisible = $attribute->getIsVisible(); } else { $systemAttributesForNonAdmin = array('sku', 'name', 'short_description', 'description', 'tier_price', 'meta_title', 'meta_description', 'meta_keyword'); if ($attribute->getIsUserDefined()) { $isAttributeVisible = $attribute->getIsVisibleOnFront(); } else { if (in_array($attribute->getAttributeCode(), $systemAttributesForNonAdmin)) { $isAttributeVisible = true; } } } return (bool) $isAttributeVisible; }
/** * Check attribute availability for super product creation * * @param Mage_Catalog_Model_Resource_Eav_Attribute $attribute * @return bool */ public function canUseAttribute(Mage_Catalog_Model_Resource_Eav_Attribute $attribute) { return $attribute->getIsGlobal() == Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL && $attribute->getIsVisible() && $attribute->getIsConfigurable() && $attribute->usesSource() && $attribute->getIsUserDefined(); }
/** * Check if specified attribute is allowed. * List of allowed attributes has higher priority over list of ignored and * blacklisted attributes. * * @param Mage_Catalog_Model_Resource_Eav_Attribute $attr Atrribute * @param array $allow Key based list of allowed attributes * @param array $ignore Key based list of attributes to ignore */ protected function _isAllowedAttribute($attr, $allow = array(), $ignore = array()) { $code = $attr->getAttributeCode(); if ($allow && !isset($allow[$code]) || isset($ignore[$code]) || isset($this->_blacklist[$code])) { return false; } return $attr->getIsVisible() || isset($this->_whitelist[$code]); }