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


PHP Mage_Adminhtml_Block_Widget_Grid::getCollection方法代码示例

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


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

示例1: getCollection

 /**
  * Get collection object
  *
  * @return AntoineK_Slider_Model_Resource_Slider_Collection
  */
 public function getCollection()
 {
     if (!parent::getCollection()) {
         $collection = Mage::getResourceModel('antoinek_slider/slider_collection');
         $this->setCollection($collection);
     }
     return parent::getCollection();
 }
开发者ID:christinecardoso,项目名称:AntoineK_Slider,代码行数:13,代码来源:Grid.php

示例2: countTotals

 /**
  * Retrieve count totals
  *
  * @param Mage_Adminhtml_Block_Widget_Grid $grid
  * @param string $from
  * @param string $to
  * @return Varien_Object
  */
 public function countTotals($grid, $from, $to)
 {
     $columns = array();
     foreach ($grid->getColumns() as $col) {
         $columns[$col->getIndex()] = array("total" => $col->getTotal(), "value" => 0);
     }
     $count = 0;
     $report = $grid->getCollection()->getReportFull($from, $to);
     foreach ($report as $item) {
         if ($grid->getSubReportSize() && $count >= $grid->getSubReportSize()) {
             continue;
         }
         $data = $item->getData();
         foreach ($columns as $field => $a) {
             if ($field !== '') {
                 $columns[$field]['value'] = $columns[$field]['value'] + (isset($data[$field]) ? $data[$field] : 0);
             }
         }
         $count++;
     }
     $data = array();
     foreach ($columns as $field => $a) {
         if ($a['total'] == 'avg') {
             if ($field !== '') {
                 if ($count != 0) {
                     $data[$field] = $a['value'] / $count;
                 } else {
                     $data[$field] = 0;
                 }
             }
         } else {
             if ($a['total'] == 'sum') {
                 if ($field !== '') {
                     $data[$field] = $a['value'];
                 }
             } else {
                 if (strpos($a['total'], '/') !== FALSE) {
                     if ($field !== '') {
                         $data[$field] = 0;
                     }
                 }
             }
         }
     }
     $totals = new Varien_Object();
     $totals->setData($data);
     return $totals;
 }
开发者ID:natxetee,项目名称:magento2,代码行数:56,代码来源:Totals.php

示例3: getCollection

 /**
  * Abstract Collection
  *
  * @return Magpleasure_Common_Model_Resource_Collection_Abstract
  */
 public function getCollection()
 {
     return parent::getCollection();
 }
开发者ID:protechhelp,项目名称:gamamba,代码行数:9,代码来源:Grid.php

示例4: afterGridPrepareCollection

 public function afterGridPrepareCollection(Mage_Adminhtml_Block_Widget_Grid $grid)
 {
     $blockType = $grid->getType();
     $blockId = $grid->getId();
     if (!is_null($model = $this->_getGridModel($blockType, $blockId, true)) && !$model->getDisabled()) {
         if ($grid->getCollection()) {
             // Check grid model against grid columns
             $grid->getCollection()->load();
             $applyFromCollection = $model->checkColumnsAgainstGridBlock($grid);
             // Apply it to grid block (only apply from collection if it could be checked)
             $model->applyColumnsToGridBlock($grid, $applyFromCollection);
             // Finish to prepare grid collection
             $grid->blcg_finishPrepareCollection();
         } else {
             // If grid has no collection, check and apply directly
             $model->checkColumnsAgainstGridBlock($grid);
             $model->applyColumnsToGridBlock($grid, false);
         }
     }
 }
开发者ID:luizventurote,项目名称:mage-enhanced-admin-grids,代码行数:20,代码来源:Observer.php

示例5: getCollection

 /**
  * Return collection object
  *
  * @return Varien_Data_Collection
  */
 public function getCollection()
 {
     $collection = parent::getCollection();
     if ($this->_blcg_mustSelectAdditionalAttributes && $collection instanceof Mage_Eav_Model_Entity_Collection_Abstract && count($this->_blcg_additionalAttributes)) {
         $this->_blcg_mustSelectAdditionalAttributes = false;
         foreach ($this->_blcg_additionalAttributes as $attribute) {
             $collection->joinAttribute($attribute['alias'], $attribute['attribute'], $attribute['bind'], $attribute['filter'], $attribute['join_type'], $attribute['store_id']);
         }
     }
     return $collection;
 }
开发者ID:aram93,项目名称:mage-enhanced-admin-grids,代码行数:16,代码来源:Rewrite.php

示例6: checkColumnsAgainstGridBlock

 /**
  * Check values against grid block instance, and save up-to-date values
  * 
  * @param Mage_Adminhtml_Block_Widget_Grid $grid Grid block instance
  * @return bool Whether we could check collection columns (if false, using them could be "dangerous")
  */
 public function checkColumnsAgainstGridBlock(Mage_Adminhtml_Block_Widget_Grid $grid)
 {
     $foundGridIds = array();
     $gridIndexes = array();
     // Grid columns
     foreach ($grid->getColumns() as $column) {
         $columnId = $column->getId();
         if (isset($this->_columns[$columnId])) {
             // Existing column : update its base values (all values that cannot be changed by user)
             $previousOrigin = $this->_columns[$columnId]['origin'];
             $this->_columns[$columnId] = array_merge($this->_columns[$columnId], array('id' => $columnId, 'index' => $column->getIndex(), 'origin' => self::GRID_COLUMN_ORIGIN_GRID, 'is_system' => $column->getIsSystem() ? 1 : 0, 'missing' => 0));
             if (!$this->isGridColumnOrigin($previousOrigin)) {
                 // If column did not previously come from grid, refresh origin IDs
                 unset($this->_originIds[$previousOrigin][array_search($columnId, $this->_originIds[$previousOrigin])]);
                 $this->_originIds[self::GRID_COLUMN_ORIGIN_GRID][] = $columnId;
             }
         } else {
             // New column
             $this->_addColumnFromBlock($column, $this->_getNextOrder());
         }
         $gridIndexes[] = $column->getIndex();
         $foundGridIds[] = $columnId;
     }
     $foundCollectionIds = array();
     $checkedCollection = false;
     // Collection columns
     if ($grid->getCollection() && $grid->getCollection()->count() > 0) {
         // Update collection  columns if possible
         $item = $grid->getCollection()->getFirstItem();
         $checkedCollection = true;
         foreach ($item->getData() as $key => $value) {
             if (is_scalar($value) || is_null($value)) {
                 if (isset($this->_columns[$key])) {
                     // Existing column
                     $previousOrigin = $this->_columns[$key]['origin'];
                     if (!in_array($key, $foundGridIds, true)) {
                         // Existing column that already came from collection, or not found anymore in the grid
                         if (!in_array($key, $gridIndexes, true)) {
                             // If it doesnt now collide with a grid index, update its base values
                             $this->_columns[$key] = array_merge($this->_columns[$key], array('id' => $key, 'index' => $key, 'origin' => self::GRID_COLUMN_ORIGIN_COLLECTION, 'is_system' => 0, 'missing' => 0));
                             if (!$this->isCollectionColumnOrigin($previousOrigin)) {
                                 // If column did not previously come from collection, remove it from its previous origin
                                 unset($this->_originIds[$previousOrigin][array_search($key, $this->_originIds[$previousOrigin])]);
                                 $this->_originIds[self::GRID_COLUMN_ORIGIN_COLLECTION][] = $key;
                             }
                             $foundCollectionIds[] = $key;
                         } else {
                             // If it does now collide with a grid index, remove it
                             unset($this->_columns[$key]);
                         }
                     }
                     // Existing column from the grid, already handled
                 } else {
                     if (!in_array($key, $foundGridIds, true) && !in_array($key, $gridIndexes, true)) {
                         // New column if no collision
                         $this->_addColumnFromCollection($key, $this->_getNextOrder());
                         $foundCollectionIds[] = $key;
                     }
                 }
             }
         }
     }
     // Attributes columns
     $foundAttributesIds = array();
     if ($this->canHaveAttributeColumns($this->getBlockType())) {
         $columnsIds = $this->_originIds[self::GRID_COLUMN_ORIGIN_ATTRIBUTE];
         $attributes = $this->getAvailableAttributesCodes();
         foreach ($columnsIds as $columnId) {
             // Verify attributes existences
             if (in_array($this->_columns[$columnId]['index'], $attributes, true)) {
                 $this->_columns[$columnId]['missing'] = 0;
                 $foundAttributesIds[] = $columnId;
             }
         }
     }
     // Custom columns
     $foundCustomIds = array();
     if ($this->canHaveCustomColumns()) {
         $columnsIds = $this->_originIds[self::GRID_COLUMN_ORIGIN_CUSTOM];
         $availableCodes = $this->getAvailableCustomColumnsCodes(true);
         foreach ($columnsIds as $columnId) {
             // Verify custom columns existence / match
             if (in_array($this->_columns[$columnId]['index'], $availableCodes, true)) {
                 $this->_columns[$columnId]['missing'] = 0;
                 $foundCustomIds[] = $columnId;
             }
         }
     }
     // Mark found to be missing columns as such
     $foundIds = array_merge($foundGridIds, $foundCollectionIds, $foundAttributesIds, $foundCustomIds);
     $missingIds = array_diff(array_keys($this->_columns), $foundIds);
     foreach ($missingIds as $missingId) {
         if ($checkedCollection || !$this->isCollectionColumnOrigin($this->_columns[$missingId]['origin'])) {
             $this->_columns[$missingId]['missing'] = 1;
//.........这里部分代码省略.........
开发者ID:xiaoguizhidao,项目名称:blingjewelry-prod,代码行数:101,代码来源:Grid.php


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