Public Member Functions | |
addStoreFilterId ($storeId) | |
addStoreFilter ($storeIds) | |
addProductFilterId ($productId) | |
addFieldToFilter ($field, $condition=null) | |
Protected Member Functions | |
_construct () | |
_initSelect () | |
_joinTables () |
Definition at line 34 of file Collection.php.
_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
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'), )
string|array | $attribute | |
null|string|array | $condition |
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
array|int | $storeIds |
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
int | $storeId |
Definition at line 54 of file Collection.php.
00055 { 00056 return $this->addStoreFilter($storeId); 00057 }