Mage_Eav_Model_Mysql4_Entity_Attribute_Option_Collection Class Reference

Inheritance diagram for Mage_Eav_Model_Mysql4_Entity_Attribute_Option_Collection:

Mage_Core_Model_Mysql4_Collection_Abstract Varien_Data_Collection_Db Varien_Data_Collection

List of all members.

Public Member Functions

 _construct ()
 setAttributeFilter ($setId)
 setStoreFilter ($storeId=null, $useDefaultValue=true)
 setIdFilter ($id)
 toOptionArray ($valueKey= 'value')
 setPositionOrder ($dir= 'ASC', $sortAlpha=false)

Protected Attributes

 $_optionValueTable


Detailed Description

Definition at line 34 of file Collection.php.


Member Function Documentation

_construct (  ) 

Initialization here

Reimplemented from Mage_Core_Model_Mysql4_Collection_Abstract.

Definition at line 38 of file Collection.php.

00039     {
00040         $this->_init('eav/entity_attribute_option');
00041         $this->_optionValueTable = Mage::getSingleton('core/resource')->getTableName('eav/attribute_option_value');
00042     }

setAttributeFilter ( setId  ) 

Definition at line 44 of file Collection.php.

00045     {
00046         $this->getSelect()->where('main_table.attribute_id=?', $setId);
00047         return $this;
00048     }

setIdFilter ( id  ) 

Definition at line 80 of file Collection.php.

00081     {
00082         if (is_array($id)) {
00083             $this->getSelect()->where('main_table.option_id IN (?)', $id);
00084         }
00085         else {
00086             $this->getSelect()->where('main_table.option_id=?', $id);
00087         }
00088         return $this;
00089     }

setPositionOrder ( dir = 'ASC',
sortAlpha = false 
)

Definition at line 96 of file Collection.php.

00097     {
00098         $this->setOrder('main_table.sort_order', $dir);
00099         // sort alphabetically by values in admin
00100         if ($sortAlpha) {
00101             $this->getSelect()->joinLeft(array('sort_alpha_value' => $this->_optionValueTable),
00102                 'sort_alpha_value.option_id=main_table.option_id AND sort_alpha_value.store_id=0', 'value'
00103             );
00104             $this->setOrder('sort_alpha_value.value', $dir);
00105         }
00106         return $this;
00107     }

setStoreFilter ( storeId = null,
useDefaultValue = true 
)

Definition at line 50 of file Collection.php.

00051     {
00052         if (is_null($storeId)) {
00053             $storeId = Mage::app()->getStore()->getId();
00054         }
00055         $sortBy = 'store_default_value';
00056         if ($useDefaultValue) {
00057             $this->getSelect()
00058                 ->join(array('store_default_value'=>$this->_optionValueTable),
00059                     'store_default_value.option_id=main_table.option_id',
00060                     array('default_value'=>'value'))
00061                 ->joinLeft(array('store_value'=>$this->_optionValueTable),
00062                     'store_value.option_id=main_table.option_id AND '.$this->getConnection()->quoteInto('store_value.store_id=?', $storeId),
00063                     array('store_value'=>'value',
00064                     'value' => new Zend_Db_Expr('IFNULL(store_value.value,store_default_value.value)')))
00065                 ->where($this->getConnection()->quoteInto('store_default_value.store_id=?', 0));
00066         }
00067         else {
00068             $sortBy = 'store_value';
00069             $this->getSelect()
00070                 ->joinLeft(array('store_value'=>$this->_optionValueTable),
00071                     'store_value.option_id=main_table.option_id AND '.$this->getConnection()->quoteInto('store_value.store_id=?', $storeId),
00072                     'value')
00073                 ->where($this->getConnection()->quoteInto('store_value.store_id=?', $storeId));
00074         }
00075         $this->setOrder("{$sortBy}.value", 'ASC');
00076 
00077         return $this;
00078     }

toOptionArray ( valueKey = 'value'  ) 

Definition at line 91 of file Collection.php.

00092     {
00093         return $this->_toOptionArray('option_id', $valueKey);
00094     }


Member Data Documentation

$_optionValueTable [protected]

Definition at line 36 of file Collection.php.


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

Generated on Sat Jul 4 17:24:12 2009 for Magento by  doxygen 1.5.8