Mage_Catalog_Model_Config Class Reference

Inheritance diagram for Mage_Catalog_Model_Config:

Mage_Eav_Model_Config

List of all members.

Public Member Functions

 loadAttributeSets ()
 getAttributeSetName ($entityTypeId, $id)
 getAttributeSetId ($entityTypeId, $name)
 loadAttributeGroups ()
 getAttributeGroupName ($attributeSetId, $id)
 getAttributeGroupId ($attributeSetId, $name)
 loadProductTypes ()
 getProductTypeId ($name)
 getProductTypeName ($id)
 getSourceOptionId ($source, $value)
 getProductAttributes ()
 getProductCollectionAttributes ()
 getAttributesUsedInProductListing ()
 getAttributesUsedForSortBy ()
 getAttributeUsedForSortByArray ()
 getProductListDefaultSortBy ($store=null)

Public Attributes

const XML_PATH_LIST_DEFAULT_SORT_BY = 'catalog/frontend/default_sort_by'
const XML_PATH_PRODUCT_COLLECTION_ATTRIBUTES = 'frontend/product/collection/attributes'

Protected Member Functions

 _construct ()
 _getResource ()

Protected Attributes

 $_attributeSetsById
 $_attributeSetsByName
 $_attributeGroupsById
 $_attributeGroupsByName
 $_productTypesById
 $_productAttributes
 $_usedInProductListing
 $_usedForSortBy


Detailed Description

Definition at line 28 of file Config.php.


Member Function Documentation

_construct (  )  [protected]

Initialize resource model

Definition at line 67 of file Config.php.

00068     {
00069         $this->_init('catalog/config');
00070     }

_getResource (  )  [protected]

Retrieve resource model

Returns:
Mage_Catalog_Model_Resource_Eav_Mysql4_Config

Definition at line 256 of file Config.php.

00257     {
00258         return Mage::getResourceModel('catalog/config');
00259     }

getAttributeGroupId ( attributeSetId,
name 
)

Definition at line 153 of file Config.php.

00154     {
00155         if (is_numeric($name)) {
00156             return $name;
00157         }
00158 
00159         $this->loadAttributeGroups();
00160 
00161         if (!is_numeric($attributeSetId)) {
00162             $attributeSetId = $this->getAttributeSetId($attributeSetId);
00163         }
00164         $name = strtolower($name);
00165         return isset($this->_attributeGroupsById[$attributeSetId][$name]) ? $this->_attributeGroupsById[$attributeSetId][$name] : false;
00166     }

getAttributeGroupName ( attributeSetId,
id 
)

Definition at line 139 of file Config.php.

00140     {
00141         if (!is_numeric($id)) {
00142             return $id;
00143         }
00144 
00145         $this->loadAttributeGroups();
00146 
00147         if (!is_numeric($attributeSetId)) {
00148             $attributeSetId = $this->getAttributeSetId($attributeSetId);
00149         }
00150         return isset($this->_attributeGroupsById[$attributeSetId][$id]) ? $this->_attributeGroupsById[$attributeSetId][$id] : false;
00151     }

getAttributeSetId ( entityTypeId,
name 
)

Definition at line 105 of file Config.php.

00106     {
00107         if (is_numeric($name)) {
00108             return $name;
00109         }
00110         $this->loadAttributeSets();
00111 
00112         if (!is_numeric($entityTypeId)) {
00113             $entityTypeId = $this->getEntityType($entityTypeId)->getId();
00114         }
00115         $name = strtolower($name);
00116         return isset($this->_attributeSetsByName[$entityTypeId][$name]) ? $this->_attributeSetsByName[$entityTypeId][$name] : false;
00117     }

getAttributeSetName ( entityTypeId,
id 
)

Definition at line 92 of file Config.php.

00093     {
00094         if (!is_numeric($id)) {
00095             return $id;
00096         }
00097         $this->loadAttributeSets();
00098 
00099         if (!is_numeric($entityTypeId)) {
00100             $entityTypeId = $this->getEntityType($entityTypeId)->getId();
00101         }
00102         return isset($this->_attributeSetsById[$entityTypeId][$id]) ? $this->_attributeSetsById[$entityTypeId][$id] : false;
00103     }

getAttributesUsedForSortBy (  ) 

Retrieve Attributes array used for sort by

Returns:
array

Definition at line 288 of file Config.php.

00288                                                  {
00289         if (is_null($this->_usedForSortBy)) {
00290             $this->_usedForSortBy = array();
00291             $entityType     = 'catalog_product';
00292             $attributesData = $this->_getResource()
00293                 ->getAttributesUsedForSortBy();
00294             Mage::getSingleton('eav/config')
00295                 ->importAttributesData($entityType, $attributesData);
00296             foreach ($attributesData as $attributeData) {
00297                 $attributeCode = $attributeData['attribute_code'];
00298                 $this->_usedForSortBy[$attributeCode] = Mage::getSingleton('eav/config')
00299                     ->getAttribute($entityType, $attributeCode);
00300             }
00301         }
00302         return $this->_usedForSortBy;
00303     }

getAttributesUsedInProductListing (  ) 

Retrieve Attributes used in product listing

Returns:
array

Definition at line 266 of file Config.php.

00266                                                         {
00267         if (is_null($this->_usedInProductListing)) {
00268             $this->_usedInProductListing = array();
00269             $entityType = 'catalog_product';
00270             $attributesData = $this->_getResource()
00271                 ->getAttributesUsedInListing();
00272             Mage::getSingleton('eav/config')
00273                 ->importAttributesData($entityType, $attributesData);
00274             foreach ($attributesData as $attributeData) {
00275                 $attributeCode = $attributeData['attribute_code'];
00276                 $this->_usedInProductListing[$attributeCode] = Mage::getSingleton('eav/config')
00277                     ->getAttribute($entityType, $attributeCode);
00278             }
00279         }
00280         return $this->_usedInProductListing;
00281     }

getAttributeUsedForSortByArray (  ) 

Retrieve Attributes Used for Sort by as array key = code, value = name

Returns:
array

Definition at line 311 of file Config.php.

00312     {
00313         $options = array(
00314             'position'  => Mage::helper('catalog')->__('Position')
00315         );
00316         foreach ($this->getAttributesUsedForSortBy() as $attribute) {
00317             /* @var $attribute Mage_Eav_Model_Entity_Attribute_Abstract */
00318             $options[$attribute->getAttributeCode()] = Mage::helper('catalog')->__($attribute->getFrontendLabel());
00319         }
00320 
00321         return $options;
00322     }

getProductAttributes (  ) 

Load Product attributes

Returns:
array

Definition at line 230 of file Config.php.

00231     {
00232         if (is_null($this->_productAttributes)) {
00233             $this->_productAttributes = array_keys($this->getAttributesUsedInProductListing());
00234         }
00235         return $this->_productAttributes;
00236     }

getProductCollectionAttributes (  ) 

Retrieve Product Collection Attributes from XML config file Used only for install/upgrade

Returns:
array

Definition at line 244 of file Config.php.

00244                                                      {
00245         $attributes = Mage::getConfig()
00246             ->getNode(self::XML_PATH_PRODUCT_COLLECTION_ATTRIBUTES)
00247             ->asArray();
00248         return array_keys($attributes);;
00249     }

getProductListDefaultSortBy ( store = null  ) 

Retrieve Product List Default Sort By

Parameters:
mixed $store
Returns:
string

Definition at line 330 of file Config.php.

00330                                                                {
00331         return Mage::getStoreConfig(self::XML_PATH_LIST_DEFAULT_SORT_BY, $store);
00332     }

getProductTypeId ( name  ) 

Definition at line 192 of file Config.php.

00193     {
00194         if (is_numeric($name)) {
00195             return $name;
00196         }
00197 
00198         $this->loadProductTypes();
00199 
00200         $name = strtolower($name);
00201         return isset($this->_productTypesByName[$name]) ? $this->_productTypesByName[$name] : false;
00202     }

getProductTypeName ( id  ) 

Definition at line 204 of file Config.php.

00205     {
00206         if (!is_numeric($id)) {
00207             return $id;
00208         }
00209 
00210         $this->loadProductTypes();
00211 
00212         return isset($this->_productTypesById[$id]) ? $this->_productTypesById[$id] : false;
00213     }

getSourceOptionId ( source,
value 
)

Definition at line 215 of file Config.php.

00216     {
00217         foreach ($source->getAllOptions() as $option) {
00218             if (strcasecmp($option['label'], $value)==0 || $option['value'] == $value) {
00219                 return $option['value'];
00220             }
00221         }
00222         return null;
00223     }

loadAttributeGroups (  ) 

Definition at line 119 of file Config.php.

00120     {
00121         if ($this->_attributeGroupsById) {
00122             return $this;
00123         }
00124 
00125         $attributeSetCollection = Mage::getResourceModel('eav/entity_attribute_group_collection')
00126             ->load();
00127 
00128         $this->_attributeGroupsById = array();
00129         $this->_attributeGroupsByName = array();
00130         foreach ($attributeSetCollection as $id=>$attributeGroup) {
00131             $attributeSetId = $attributeGroup->getAttributeSetId();
00132             $name = $attributeGroup->getAttributeGroupName();
00133             $this->_attributeGroupsById[$attributeSetId][$id] = $name;
00134             $this->_attributeGroupsByName[$attributeSetId][strtolower($name)] = $id;
00135         }
00136         return $this;
00137     }

loadAttributeSets (  ) 

Definition at line 72 of file Config.php.

00073     {
00074         if ($this->_attributeSetsById) {
00075             return $this;
00076         }
00077 
00078         $attributeSetCollection = Mage::getResourceModel('eav/entity_attribute_set_collection')
00079             ->load();
00080 
00081         $this->_attributeSetsById = array();
00082         $this->_attributeSetsByName = array();
00083         foreach ($attributeSetCollection as $id=>$attributeSet) {
00084             $entityTypeId = $attributeSet->getEntityTypeId();
00085             $name = $attributeSet->getAttributeSetName();
00086             $this->_attributeSetsById[$entityTypeId][$id] = $name;
00087             $this->_attributeSetsByName[$entityTypeId][strtolower($name)] = $id;
00088         }
00089         return $this;
00090     }

loadProductTypes (  ) 

Definition at line 168 of file Config.php.

00169     {
00170         if ($this->_productTypesById) {
00171             return $this;
00172         }
00173 
00174         /*
00175         $productTypeCollection = Mage::getResourceModel('catalog/product_type_collection')
00176             ->load();
00177         */
00178         $productTypeCollection = Mage::getModel('catalog/product_type')
00179             ->getOptionArray();
00180 
00181         $this->_productTypesById = array();
00182         $this->_productTypesByName = array();
00183         foreach ($productTypeCollection as $id=>$type) {
00184             //$name = $type->getCode();
00185             $name = $type;
00186             $this->_productTypesById[$id] = $name;
00187             $this->_productTypesByName[strtolower($name)] = $id;
00188         }
00189         return $this;
00190     }


Member Data Documentation

$_attributeGroupsById [protected]

Definition at line 35 of file Config.php.

$_attributeGroupsByName [protected]

Definition at line 36 of file Config.php.

$_attributeSetsById [protected]

Definition at line 32 of file Config.php.

$_attributeSetsByName [protected]

Definition at line 33 of file Config.php.

$_productAttributes [protected]

Definition at line 45 of file Config.php.

$_productTypesById [protected]

Definition at line 38 of file Config.php.

$_usedForSortBy [protected]

Definition at line 59 of file Config.php.

$_usedInProductListing [protected]

Definition at line 52 of file Config.php.

const XML_PATH_LIST_DEFAULT_SORT_BY = 'catalog/frontend/default_sort_by'

Definition at line 30 of file Config.php.

const XML_PATH_PRODUCT_COLLECTION_ATTRIBUTES = 'frontend/product/collection/attributes'

Definition at line 61 of file Config.php.


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:23:38 2009 for Magento by  doxygen 1.5.8