当前位置: 首页>>代码示例>>PHP>>正文


PHP Varien_Data_Collection::getSize方法代码示例

本文整理汇总了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;
 }
开发者ID:AleksNesh,项目名称:pandora,代码行数:30,代码来源:Speed.php

示例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);
 }
开发者ID:styladev,项目名称:magentoStylaConnect,代码行数:24,代码来源:V1.php


注:本文中的Varien_Data_Collection::getSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。