Mage_CatalogIndex_Model_Mysql4_Attribute Class Reference

Inheritance diagram for Mage_CatalogIndex_Model_Mysql4_Attribute:

Mage_CatalogIndex_Model_Mysql4_Abstract Mage_Core_Model_Mysql4_Abstract Mage_Core_Model_Resource_Abstract

List of all members.

Public Member Functions

 getFilteredEntities ($attribute, $filter, $entityFilter)
 getCount ($attribute, $entitySelect)
 applyFilterToCollection ($collection, $attribute, $value)

Protected Member Functions

 _construct ()


Detailed Description

Attribute index resource model

Author:
Magento Core Team <core@magentocommerce.com>

Definition at line 33 of file Attribute.php.


Member Function Documentation

_construct (  )  [protected]

Resource initialization

Reimplemented from Mage_CatalogIndex_Model_Mysql4_Abstract.

Definition at line 35 of file Attribute.php.

00036     {
00037         $this->_init('catalogindex/eav', 'index_id');
00038     }

applyFilterToCollection ( collection,
attribute,
value 
)

Will be used after SQL review

Definition at line 82 of file Attribute.php.

00083     {
00084         /**
00085          * Will be used after SQL review
00086          */
00087 //        if ($collection->isEnabledFlat()) {
00088 //            $collection->getSelect()->where("e.{$attribute->getAttributeCode()}=?", $value);
00089 //            return $this;
00090 //        }
00091 
00092         $alias = 'attr_index_'.$attribute->getId();
00093         $collection->getSelect()->join(
00094             array($alias => $this->getMainTable()),
00095             $alias.'.entity_id=e.entity_id',
00096             array()
00097         )
00098         ->where($alias.'.store_id = ?', $this->getStoreId())
00099         ->where($alias.'.attribute_id = ?', $attribute->getId())
00100         ->where($alias.'.value = ?', $value);
00101         return $this;
00102     }

getCount ( attribute,
entitySelect 
)

Definition at line 55 of file Attribute.php.

00056     {
00057         $select = clone $entitySelect;
00058         $select->reset(Zend_Db_Select::COLUMNS);
00059         $select->reset(Zend_Db_Select::ORDER);
00060         $select->reset(Zend_Db_Select::LIMIT_COUNT);
00061         $select->reset(Zend_Db_Select::LIMIT_OFFSET);
00062 
00063         $fields = array('count'=>'COUNT(index.entity_id)', 'index.value');
00064 
00065         $select->from('', $fields)
00066             ->join(array('index'=>$this->getMainTable()), 'index.entity_id=e.entity_id', array())
00067             ->where('index.store_id = ?', $this->getStoreId())
00068             ->where('index.attribute_id = ?', $attribute->getId())
00069             ->group('index.value');
00070 
00071         $select = $select->__toString();
00072 //        $alias = $this->_getReadAdapter()->quoteTableAs($this->getMainTable(), 'index');
00073         $result = $this->_getReadAdapter()->fetchAll($select);
00074 
00075         $counts = array();
00076         foreach ($result as $row) {
00077             $counts[$row['value']] = $row['count'];
00078         }
00079         return $counts;
00080     }

getFilteredEntities ( attribute,
filter,
entityFilter 
)

Definition at line 40 of file Attribute.php.

00041     {
00042         $select = $this->_getReadAdapter()->select();
00043 
00044         $select
00045             ->from($this->getMainTable(), 'entity_id')
00046             ->distinct(true)
00047             ->where('entity_id in (?)', $entityFilter)
00048             ->where('store_id = ?', $this->getStoreId())
00049             ->where('attribute_id = ?', $attribute->getId())
00050             ->where('value = ?', $filter);
00051 
00052         return $this->_getReadAdapter()->fetchCol($select);
00053     }


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

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