本文整理匯總了PHP中Varien_Data_Collection::getSize方法的典型用法代碼示例。如果您正苦於以下問題:PHP Varien_Data_Collection::getSize方法的具體用法?PHP Varien_Data_Collection::getSize怎麽用?PHP Varien_Data_Collection::getSize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Varien_Data_Collection
的用法示例。
在下文中一共展示了Varien_Data_Collection::getSize方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getSearchResultCollection
private function getSearchResultCollection()
{
$collection = new Varien_Data_Collection();
$index = Mage::helper('searchindex/index')->getIndex('mage_catalog_product');
$storeId = $this->getStoreId();
if (($query = $this->getRequest()->getParam('q')) && $index) {
$engine = Mage::helper('searchindex')->getSearchEngine();
$start = microtime(true);
try {
$result = $engine->query($query, $storeId, $index);
} catch (Exception $e) {
try {
$engine = Mage::getModel('searchsphinx/engine_fulltext');
$result = $engine->query($query, $storeId, $index);
} catch (Exception $e) {
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
$result = array();
}
}
$end = microtime(true);
$this->searchTime = round($end - $start, 4);
foreach ($result as $productId => $relevance) {
$varienObject = new Varien_Object();
$varienObject->addData(array('id' => $productId, 'relevance' => $relevance));
$collection->addItem($varienObject);
}
$this->resultSize = $collection->getSize();
}
return $collection;
}
示例2: _addPagingHeaderData
/**
* @param Varien_Data_Collection $collection
* @throws Exception
*/
protected function _addPagingHeaderData(Varien_Data_Collection $collection)
{
$links = array();
$totalCount = $collection->getSize();
$pageSize = $collection->getPageSize();
$totalPageCount = ceil($totalCount / $pageSize);
$currentPage = $collection->getCurPage();
if ($currentPage === null) {
$currentPage = 1;
}
if ($currentPage > 1) {
$links[] = $this->_getPageLink(1, 'first');
$links[] = $this->_getPageLink($currentPage - 1, 'prev');
}
if ($currentPage < $totalPageCount) {
$links[] = $this->_getPageLink($currentPage + 1, 'next');
$links[] = $this->_getPageLink($totalPageCount, 'last');
}
$this->getResponse()->setHeader('Link', implode(", ", $links))->setHeader('X-Total-Count', $totalCount)->setHeader('X-Total-Pages', $totalPageCount)->setHeader('X-Current-Page', $currentPage);
}