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


PHP Mage_Adminhtml_Block_Widget_Grid::_exportIterateCollection方法代码示例

本文整理汇总了PHP中Mage_Adminhtml_Block_Widget_Grid::_exportIterateCollection方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Adminhtml_Block_Widget_Grid::_exportIterateCollection方法的具体用法?PHP Mage_Adminhtml_Block_Widget_Grid::_exportIterateCollection怎么用?PHP Mage_Adminhtml_Block_Widget_Grid::_exportIterateCollection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mage_Adminhtml_Block_Widget_Grid的用法示例。


在下文中一共展示了Mage_Adminhtml_Block_Widget_Grid::_exportIterateCollection方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _exportIterateCollection

 /**
  * Iterate collection and call callback method per item
  * For callback method first argument always is item object
  *
  * @param string $callback
  * @param array $args additional arguments for callback method
  * @return Mage_Adminhtml_Block_Widget_Grid
  */
 public function _exportIterateCollection($callback, array $args)
 {
     if (!is_array($this->_blcg_exportInfos)) {
         return parent::_exportIterateCollection($callback, $args);
     } else {
         // Custom export
         if (!is_null($this->_blcg_exportedCollection)) {
             $originalCollection = $this->_blcg_exportedCollection;
         } else {
             $originalCollection = $this->getCollection();
         }
         if ($originalCollection->isLoaded()) {
             // Should do the trick in all exceptions (if not loaded page size can be changed)
             Mage::throwException(Mage::helper('customgrid')->__('This grid does not seem to be compatible with the custom export. If you wish to report this problem, please indicate this class name : "%s"', get_class($this)));
         }
         // 1000 up to 1.4, class var from 1.5
         $exportPageSize = isset($this->_exportPageSize) ? $this->_exportPageSize : 1000;
         $infos = $this->_blcg_exportInfos;
         $total = isset($infos['custom_size']) ? intval($infos['custom_size']) : (isset($infos['size']) ? intval($infos['size']) : $exportPageSize);
         if ($total <= 0) {
             return;
         }
         $fromResult = isset($infos['from_result']) ? intval($infos['from_result']) : 1;
         $pageSize = min($total, $exportPageSize);
         $page = ceil($fromResult / $pageSize);
         $pitchSize = $fromResult > 1 ? $fromResult - 1 - ($page - 1) * $pageSize : 0;
         $break = false;
         $count = null;
         while ($break !== true) {
             $collection = clone $originalCollection;
             $collection->setPageSize($pageSize);
             $collection->setCurPage($page);
             if (!is_null($this->_blcg_typeModel)) {
                 $this->_blcg_typeModel->beforeGridExportLoadCollection($this, $collection);
             }
             $collection->load();
             if (!is_null($this->_blcg_typeModel)) {
                 $this->_blcg_typeModel->afterGridExportLoadCollection($this, $collection);
             }
             if (is_null($count)) {
                 $count = $collection->getSize();
                 $total = min(max(0, $count - $fromResult + 1), $total);
                 if ($total == 0) {
                     $break = true;
                     continue;
                 }
                 $first = true;
                 $exported = 0;
             }
             $page++;
             $i = 0;
             foreach ($collection as $item) {
                 if ($first) {
                     if ($i++ < $pitchSize) {
                         continue;
                     } else {
                         $first = false;
                     }
                 }
                 if (++$exported > $total) {
                     $break = true;
                     break;
                 }
                 call_user_func_array(array($this, $callback), array_merge(array($item), $args));
             }
         }
     }
 }
开发者ID:aram93,项目名称:mage-enhanced-admin-grids,代码行数:76,代码来源:Rewrite.php


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