Mage_GoogleBase_Model_Mysql4_Item_Collection Class Reference

Inheritance diagram for Mage_GoogleBase_Model_Mysql4_Item_Collection:

Mage_Core_Model_Mysql4_Collection_Abstract Varien_Data_Collection_Db Varien_Data_Collection

List of all members.

Public Member Functions

 addStoreFilterId ($storeId)
 addStoreFilter ($storeIds)
 addProductFilterId ($productId)
 addFieldToFilter ($field, $condition=null)

Protected Member Functions

 _construct ()
 _initSelect ()
 _joinTables ()


Detailed Description

Definition at line 34 of file Collection.php.


Member Function Documentation

_construct (  )  [protected]

Initialization here

Reimplemented from Mage_Core_Model_Mysql4_Collection_Abstract.

Definition at line 36 of file Collection.php.

00037     {
00038         $this->_init('googlebase/item');
00039     }

_initSelect (  )  [protected]

Reimplemented from Mage_Core_Model_Mysql4_Collection_Abstract.

Definition at line 41 of file Collection.php.

00042     {
00043         parent::_initSelect();
00044         $this->_joinTables();
00045         return $this;
00046     }

_joinTables (  )  [protected]

Join product and type data

Returns:
Mage_GoogleBase_Model_Mysql4_Item_Collection

Definition at line 92 of file Collection.php.

00093     {
00094         $entityType = Mage::getSingleton('eav/config')->getEntityType('catalog_product');
00095         $attribute = Mage::getModel('eav/config')->getAttribute($entityType->getEntityTypeId(),'name');
00096 
00097         $joinConditionDefault = sprintf("p_d.attribute_id=%d AND p_d.store_id='0' AND main_table.product_id=p_d.entity_id",
00098             $attribute->getAttributeId()
00099         );
00100         $joinCondition = sprintf("p.attribute_id=%d AND p.store_id=main_table.store_id AND main_table.product_id=p.entity_id",
00101             $attribute->getAttributeId()
00102         );
00103 
00104         $this->getSelect()
00105             ->joinLeft(
00106                 array('p_d' => $attribute->getBackend()->getTable()),
00107                 $joinConditionDefault,
00108                 array());
00109 
00110         $this->getSelect()
00111             ->joinLeft(
00112                 array('p' => $attribute->getBackend()->getTable()),
00113                 $joinCondition,
00114                 array('name' => new Zend_Db_Expr('IFNULL(p.value, p_d.value)')));
00115 
00116         $this->getSelect()
00117             ->joinLeft(
00118                 array('types' => $this->getTable('googlebase/types')),
00119                 'main_table.type_id=types.type_id',
00120                 array('gbase_itemtype' =>  new Zend_Db_Expr('IFNULL(types.gbase_itemtype, \''.Mage_GoogleBase_Model_Service_Item::DEFAULT_ITEM_TYPE .'\')')));
00121 
00122         return $this;
00123     }

addFieldToFilter ( field,
condition = null 
)

Add field filter to collection

If $attribute is an array will add OR condition with following format: array( array('attribute'=>'firstname', 'like'=>'test'), array('attribute'=>'lastname', 'like'=>'test'), )

See also:
self._getConditionSql for $condition
Parameters:
string|array $attribute
null|string|array $condition
Returns:
Mage_Eav_Model_Entity_Collection_Abstract

Reimplemented from Varien_Data_Collection_Db.

Definition at line 77 of file Collection.php.

00078     {
00079         if ($field == 'name') {
00080             $conditionSql = $this->_getConditionSql('p.value', $condition);
00081             $this->getSelect()->where($conditionSql);
00082         } else {
00083             parent::addFieldToFilter($field, $condition);
00084         }
00085     }

addProductFilterId ( productId  ) 

Definition at line 71 of file Collection.php.

00072     {
00073         $this->getSelect()->where('main_table.product_id=?', $productId);
00074         return $this;
00075     }

addStoreFilter ( storeIds  ) 

Filter collection by specified store ids

Parameters:
array|int $storeIds
Returns:
Mage_GoogleBase_Model_Mysql4_Item_Collection

Definition at line 65 of file Collection.php.

00066     {
00067         $this->getSelect()->where('main_table.store_id IN (?)', $storeIds);
00068         return $this;
00069     }

addStoreFilterId ( storeId  ) 

Deprecated

Parameters:
int $storeId
Returns:
Mage_GoogleBase_Model_Mysql4_Item_Collection

Definition at line 54 of file Collection.php.

00055     {
00056         return $this->addStoreFilter($storeId);
00057     }


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

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