Here are some of the functions that you can use in your collection object:-
Get Zend_Db_Select instance
$collection->getSelect();
Add select order
$collection->getSelect()->setOrder($field, $direction);
Get collection size : $collection->getSelect()->getSize(); : $collection->count()
Retrieve collection all items count : $collection->getSelect()->getSize();
Get sql select string or object
$collection->getSelect()->getSelectSql();
Field Filter to collection
If $attribute is an array will add OR condition with following format:
array(
array('attribute'=>'email', 'like'=>'ramu@%'),
array('attribute'=>'phone', 'like'=>'9759%'),
)
$collection->getSelect()->setOrder($field, $condition);
Get all data array for collection: $collection->getSelect()->getData();
Set select distinct : $collection->getSelect()->distinct($flag);
Print and/or log query : $collection->getSelect()->printLogQuery(true, true);
Reset loaded for collection data array : $collection->getSelect()->resetData();
Get current collection page : $collection->getSelect()->getCurPage();
Retrieve collection last page number : $collection->getSelect()->getLastPageNumber();
Retrieve collection page size :$collection->getSelect()->getPageSize();
Clear collection : $collection->getSelect()->clear();
Retrieve collection first item : $collection->getSelect()->getFirstItem();
Retrieve collection last item : $collection->getSelect()->getLastItem();
Retrieve collection items : $collection->getSelect()->getItems();
I dont know which fool says that this is his copy righted material...
ReplyDeleteThis is a 100% open source blog for magento lovers.
-
Author