Public Member Functions | |
_construct () | |
addFieldToFilter ($field, $condition=null) | |
addStoresFilter ($store) | |
addStoreFilter ($storeId, $withAdmin=true) | |
addStoreData () | |
addSelectStores () |
Definition at line 34 of file Collection.php.
_construct | ( | ) |
Initialization here
Reimplemented from Mage_Core_Model_Mysql4_Collection_Abstract.
Definition at line 36 of file Collection.php.
00037 { 00038 $this->_init('poll/poll'); 00039 }
addFieldToFilter | ( | $ | field, | |
$ | condition = null | |||
) |
Redefine default filters
string | $field | |
mixed | $condition |
Reimplemented from Varien_Data_Collection_Db.
Definition at line 48 of file Collection.php.
00049 { 00050 if ($field == 'stores') { 00051 return $this->addStoresFilter($condition); 00052 } 00053 else { 00054 return parent::addFieldToFilter($field, $condition); 00055 } 00056 }
addSelectStores | ( | ) |
Definition at line 123 of file Collection.php.
00124 { 00125 $pollId = $this->getId(); 00126 $select = $this->getConnection()->select() 00127 ->from($this->getTable('poll/poll_store')) 00128 ->where('poll_id = ?', $pollId); 00129 $result = $this->getConnection()->fetchAll($select); 00130 $stores = array(); 00131 foreach ($result as $row) { 00132 $stores[] = $row['stor_id']; 00133 } 00134 $this->setSelectStores($stores); 00135 00136 return $this; 00137 }
addStoreData | ( | ) |
Add stores data
Definition at line 93 of file Collection.php.
00094 { 00095 $pollIds = $this->getColumnValues('poll_id'); 00096 $storesToPoll = array(); 00097 00098 if (count($pollIds) > 0) { 00099 $select = $this->getConnection()->select() 00100 ->from($this->getTable('poll/poll_store')) 00101 ->where('poll_id IN(?)', $pollIds); 00102 $result = $this->getConnection()->fetchAll($select); 00103 00104 foreach ($result as $row) { 00105 if (!isset($storesToPoll[$row['poll_id']])) { 00106 $storesToPoll[$row['poll_id']] = array(); 00107 } 00108 $storesToPoll[$row['poll_id']][] = $row['store_id']; 00109 } 00110 } 00111 00112 foreach ($this as $item) { 00113 if(isset($storesToPoll[$item->getId()])) { 00114 $item->setStores($storesToPoll[$item->getId()]); 00115 } else { 00116 $item->setStores(array()); 00117 } 00118 } 00119 00120 return $this; 00121 }
addStoreFilter | ( | $ | storeId, | |
$ | withAdmin = true | |||
) |
Add Stores Filter
int|array | $storeId |
Definition at line 75 of file Collection.php.
00076 { 00077 $this->getSelect()->join( 00078 array('store_table' => $this->getTable('poll/poll_store')), 00079 'main_table.poll_id = store_table.poll_id', 00080 array() 00081 ) 00082 ->where('store_table.store_id in (?)', ($withAdmin ? array(0, $storeId) : $storeId)) 00083 ->group('main_table.poll_id'); 00084 00085 return $this; 00086 }
addStoresFilter | ( | $ | store | ) |
Deprecated
int|array | $storeId |
Definition at line 64 of file Collection.php.
00065 { 00066 return $this->addStoresFilter($store); 00067 }