Public Member Functions | |
addCustomerData () | |
addWebsiteFilter ($websiteIds) | |
Protected Member Functions | |
_construct () |
Definition at line 35 of file Collection.php.
_construct | ( | ) | [protected] |
Initialize collection model
Reimplemented from Mage_Core_Model_Mysql4_Collection_Abstract.
Definition at line 41 of file Collection.php.
00042 { 00043 $this->_init('log/visitor_online'); 00044 }
addCustomerData | ( | ) |
Add Customer data to collection
Definition at line 51 of file Collection.php.
00052 { 00053 $customer = Mage::getModel('customer/customer'); 00054 // alias => attribute_code 00055 $attributes = array( 00056 'customer_lastname' => 'lastname', 00057 'customer_firstname' => 'firstname', 00058 'customer_email' => 'email' 00059 ); 00060 00061 foreach ($attributes as $alias => $attributeCode) { 00062 $attribute = $customer->getAttribute($attributeCode); 00063 /* @var $attribute Mage_Eav_Model_Entity_Attribute_Abstract */ 00064 00065 if ($attribute->getBackendType() == 'static') { 00066 $tableAlias = 'customer_' . $attribute->getAttributeCode(); 00067 00068 $this->getSelect()->joinLeft( 00069 array($tableAlias => $attribute->getBackend()->getTable()), 00070 sprintf('%s.entity_id=main_table.customer_id', $tableAlias), 00071 array($alias => $attribute->getAttributeCode()) 00072 ); 00073 } 00074 else { 00075 $tableAlias = 'customer_' . $attribute->getAttributeCode(); 00076 00077 $joinConds = array( 00078 sprintf('%s.entity_id=main_table.customer_id', $tableAlias), 00079 $this->getConnection()->quoteInto($tableAlias . '.attribute_id=?', $attribute->getAttributeId()) 00080 ); 00081 00082 $this->getSelect()->joinLeft( 00083 array($tableAlias => $attribute->getBackend()->getTable()), 00084 join(' AND ', $joinConds), 00085 array($alias => 'value') 00086 ); 00087 } 00088 } 00089 00090 $this->setFlag('has_customer_data', true); 00091 return $this; 00092 }
addWebsiteFilter | ( | $ | websiteIds | ) |
Filter collection by specified website(s)
int|array | $websiteIds |
Definition at line 100 of file Collection.php.
00101 { 00102 if ($this->getFlag('has_customer_data')) { 00103 $this->getSelect() 00104 ->where('customer_email.website_id IN (?)', $websiteIds); 00105 } 00106 return $this; 00107 }