Public Member Functions | |
addWishlistCount () | |
getCustomerCount () | |
getSelectCountSql () | |
setOrder ($attribute, $dir='desc') | |
Protected Member Functions | |
_construct () |
Definition at line 35 of file Collection.php.
_construct | ( | ) | [protected] |
Initialize resources
Reimplemented from Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection.
Definition at line 37 of file Collection.php.
00038 { 00039 $this->_init('wishlist/wishlist'); 00040 }
addWishlistCount | ( | ) |
Definition at line 42 of file Collection.php.
00043 { 00044 $wishlistItemTable = Mage::getSingleton('core/resource')->getTableName('wishlist/item'); 00045 00046 $this->getSelect() 00047 ->from(array('wi' => $wishlistItemTable), 'count(wishlist_item_id) as wishlists') 00048 ->where('wi.product_id=e.entity_id') 00049 ->group('wi.product_id'); 00050 00051 $this->getEntity()->setStore(0); 00052 return $this; 00053 }
getCustomerCount | ( | ) |
Definition at line 55 of file Collection.php.
00056 { 00057 $this->getSelect()->reset(); 00058 $this->getSelect()->from("wishlist", array("count(wishlist_id) as wishlist_cnt")) 00059 ->group("wishlist.customer_id"); 00060 return $this;//->getItems()->; 00061 }
getSelectCountSql | ( | ) |
Get SQL for get record count
Reimplemented from Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection.
Definition at line 63 of file Collection.php.
00064 { 00065 $countSelect = clone $this->getSelect(); 00066 $countSelect->reset(Zend_Db_Select::ORDER); 00067 $countSelect->reset(Zend_Db_Select::LIMIT_COUNT); 00068 $countSelect->reset(Zend_Db_Select::LIMIT_OFFSET); 00069 $countSelect->reset(Zend_Db_Select::GROUP); 00070 00071 $sql = $countSelect->__toString(); 00072 00073 $sql = preg_replace('/^select\s+.+?\s+from\s+/is', 'select count(*) from ', $sql); 00074 00075 return $sql; 00076 }
setOrder | ( | $ | attribute, | |
$ | dir = 'desc' | |||
) |
Set sorting order
$attribute can also be an array of attributes
string|array | $attribute | |
string | $dir |
Reimplemented from Mage_Eav_Model_Entity_Collection_Abstract.
Definition at line 78 of file Collection.php.
00079 { 00080 switch ($attribute) 00081 { 00082 case 'wishlists': 00083 $this->getSelect()->order($attribute . ' ' . $dir); 00084 break; 00085 default: 00086 parent::setOrder($attribute, $dir); 00087 } 00088 00089 return $this; 00090 }