Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Member Functions | Protected Attributes
Extended Class Reference
Inheritance diagram for Extended:
Grid ExportInterface Widget Template Template AbstractBlock DataObject BlockInterface Grid Grid Product Price Stock Upsell Grid Sku Grid Chooser Grid Chooser Cart Grid Orders Cart Wishlist AbstractGrid Filter Grid Grid Grid Orders AbstractGrid Shopcart Grid Grid Grid Grid Grid Grid Grid Chooser User Roles

Public Member Functions

 getColumnSet ()
 
 getExportButtonHtml ()
 
 addExportType ($url, $label)
 
 addColumn ($columnId, $column)
 
 removeColumn ($columnId)
 
 addColumnAfter ($columnId, $column, $after)
 
 addColumnsOrder ($columnId, $after)
 
 getColumnsOrder ()
 
 sortColumnsByOrder ()
 
 getLastColumnId ()
 
 getHtml ()
 
 getMassactionIdField ()
 
 setMassactionIdField ($idField)
 
 getMassactionIdFilter ()
 
 setMassactionIdFilter ($idFilter)
 
 getMassactionBlockName ()
 
 setMassactionBlockName ($blockName)
 
 getMassactionBlock ()
 
 getMassactionBlockHtml ()
 
 getSubTotalColumns ()
 
 shouldRenderCell ($item, $column)
 
 getEmptyCellLabel ()
 
 setEmptyCellLabel ($label)
 
 getRowUrl ($item)
 
 getMultipleRows ($item)
 
 getMultipleRowColumns ()
 
 shouldRenderSubTotal ($item)
 
 getRowspan ($item, $column)
 
 isColumnGrouped ($column, $value=null)
 
 shouldRenderEmptyCell ($item, $column)
 
 getEmptyCellColspan ()
 
 getSubTotalItem ($item)
 
 getColumnCount ()
 
 setHeadersVisibility ($visible=true)
 
 getHeadersVisibility ()
 
 setFilterVisibility ($visible=true)
 
 getFilterVisibility ()
 
 setEmptyText ($text)
 
 getEmptyText ()
 
 setEmptyTextClass ($cssClass)
 
 getEmptyTextClass ()
 
 setIsCollapsed ($isCollapsed)
 
 getIsCollapsed ()
 
 _exportIterateCollection ($callback, array $args)
 
 getCsvFile ()
 
 getCsv ()
 
 getXml ()
 
 getRowRecord (\Magento\Framework\DataObject $data)
 
 getExcelFile ($sheetName='')
 
 getExcel ()
 
 getExportTypes ()
 
 setCollection ($collection)
 
 getCollection ()
 
 setCountSubTotals ($flag=true)
 
 getCountSubTotals ()
 
 setSubTotals (array $items)
 
 getSubTotals ()
 
 getMainButtonsHtml ()
 
- Public Member Functions inherited from Grid
 __construct (\Magento\Backend\Block\Template\Context $context, \Magento\Backend\Helper\Data $backendHelper, array $data=[])
 
 setCollection ($collection)
 
 getCollection ()
 
 getColumnSet ()
 
 getExportBlock ()
 
 getColumns ()
 
 getColumnCount ()
 
 getColumn ($columnId)
 
 getPreparedCollection ()
 
 getMassactionBlock ()
 
 getVarNameLimit ()
 
 getVarNamePage ()
 
 getVarNameSort ()
 
 getVarNameDir ()
 
 getVarNameFilter ()
 
 setVarNameLimit ($name)
 
 setVarNamePage ($name)
 
 setVarNameSort ($name)
 
 setVarNameDir ($name)
 
 setVarNameFilter ($name)
 
 setPagerVisibility ($visible=true)
 
 getPagerVisibility ()
 
 setMessageBlockVisibility ($visible=true)
 
 getMessageBlockVisibility ()
 
 setDefaultLimit ($limit)
 
 setDefaultPage ($page)
 
 setDefaultSort ($sort)
 
 setDefaultDir ($dir)
 
 setDefaultFilter ($filter)
 
 canDisplayContainer ()
 
 getGridUrl ()
 
 getAbsoluteGridUrl ($params=[])
 
 getParam ($paramName, $default=null)
 
 setSaveParametersInSession ($flag)
 
 getJsObjectName ()
 
 setCountTotals ($count=true)
 
 getCountTotals ()
 
 setTotals (\Magento\Framework\DataObject $totals)
 
 getTotals ()
 
 getMainButtonsHtml ()
 
 getResetFilterButtonHtml ()
 
 getSearchButtonHtml ()
 
- Public Member Functions inherited from Widget
 getId ()
 
 getSuffixId ($suffix)
 
 getHtmlId ()
 
 getCurrentUrl ($params=[])
 
 getButtonHtml ($label, $onclick, $class='', $buttonId=null, $dataAttr=[])
 
- Public Member Functions inherited from Template
 __construct (\Magento\Backend\Block\Template\Context $context, array $data=[])
 
 getFormKey ()
 
 isOutputEnabled ($moduleName=null)
 
 getAuthorization ()
 
 getToolbar ()
 
- Public Member Functions inherited from Template
 __construct (Template\Context $context, array $data=[])
 
 setTemplateContext ($templateContext)
 
 getTemplate ()
 
 setTemplate ($template)
 
 getTemplateFile ($template=null)
 
 getArea ()
 
 assign ($key, $value=null)
 
 fetchView ($fileName)
 
 getBaseUrl ()
 
 getObjectData (\Magento\Framework\DataObject $object, $key)
 
 getCacheKeyInfo ()
 
- Public Member Functions inherited from AbstractBlock
 __construct (\Magento\Framework\View\Element\Context $context, array $data=[])
 
 getJsLayout ()
 
 getRequest ()
 
 getParentBlock ()
 
 setLayout (\Magento\Framework\View\LayoutInterface $layout)
 
 getLayout ()
 
 setNameInLayout ($name)
 
 getChildNames ()
 
 setAttribute ($name, $value=null)
 
 setChild ($alias, $block)
 
 addChild ($alias, $block, $data=[])
 
 unsetChild ($alias)
 
 unsetCallChild ($alias, $callback, $result, $params)
 
 unsetChildren ()
 
 getChildBlock ($alias)
 
 getChildHtml ($alias='', $useCache=true)
 
 getChildChildHtml ($alias, $childChildAlias='', $useCache=true)
 
 getBlockHtml ($name)
 
 insert ($element, $siblingName=0, $after=true, $alias='')
 
 append ($element, $alias='')
 
 getGroupChildNames ($groupName)
 
 getChildData ($alias, $key='')
 
 getUiId ($arg1=null, $arg2=null, $arg3=null, $arg4=null, $arg5=null)
 
 getJsId ($arg1=null, $arg2=null, $arg3=null, $arg4=null, $arg5=null)
 
 getUrl ($route='', $params=[])
 
 getViewFileUrl ($fileId, array $params=[])
 
 formatDate ( $date=null, $format=\IntlDateFormatter::SHORT, $showTime=false, $timezone=null)
 
 formatTime ( $time=null, $format=\IntlDateFormatter::SHORT, $showDate=false)
 
 getModuleName ()
 
 escapeHtml ($data, $allowedTags=null)
 
 escapeJs ($string)
 
 escapeHtmlAttr ($string, $escapeSingleQuote=true)
 
 escapeCss ($string)
 
 stripTags ($data, $allowableTags=null, $allowHtmlEntities=false)
 
 escapeUrl ($string)
 
 escapeXssInUrl ($data)
 
 escapeQuote ($data, $addSlashes=false)
 
 escapeJsQuote ($data, $quote='\'')
 
 getNameInLayout ()
 
 getCacheKeyInfo ()
 
 getCacheKey ()
 
 getVar ($name, $module=null)
 
 isScopePrivate ()
 
- Public Member Functions inherited from DataObject
 __construct (array $data=[])
 
 addData (array $arr)
 
 setData ($key, $value=null)
 
 unsetData ($key=null)
 
 getData ($key='', $index=null)
 
 getDataByPath ($path)
 
 getDataByKey ($key)
 
 setDataUsingMethod ($key, $args=[])
 
 getDataUsingMethod ($key, $args=null)
 
 hasData ($key='')
 
 toArray (array $keys=[])
 
 convertToArray (array $keys=[])
 
 toXml (array $keys=[], $rootName='item', $addOpenTag=false, $addCdata=true)
 
 convertToXml (array $arrAttributes=[], $rootName='item', $addOpenTag=false, $addCdata=true)
 
 toJson (array $keys=[])
 
 convertToJson (array $keys=[])
 
 toString ($format='')
 
 __call ($method, $args)
 
 isEmpty ()
 
 serialize ($keys=[], $valueSeparator='=', $fieldSeparator=' ', $quote='"')
 
 debug ($data=null, &$objects=[])
 
 offsetSet ($offset, $value)
 
 offsetExists ($offset)
 
 offsetUnset ($offset)
 
 offsetGet ($offset)
 
- Public Member Functions inherited from BlockInterface
 toHtml ()
 
- Public Member Functions inherited from ExportInterface
 getId ()
 

Protected Member Functions

 _construct ()
 
 _prepareLayout ()
 
 _prepareColumns ()
 
 _prepareMassactionBlock ()
 
 _prepareMassaction ()
 
 _prepareMassactionColumn ()
 
 _prepareCollection ()
 
 _afterLoadCollection ()
 
 _prepareGrid ()
 
 _getFileContainerContent (array $fileData)
 
 _getExportHeaders ()
 
 _getExportTotals ()
 
 _exportCsvItem (\Magento\Framework\DataObject $item, \Magento\Framework\Filesystem\File\WriteInterface $stream)
 
- Protected Member Functions inherited from Grid
 _construct ()
 
 _setFilterValues ($data)
 
 _addColumnFilterToCollection ($column)
 
 _setCollectionOrder ($column)
 
 _prepareCollection ()
 
 _preparePage ()
 
 _prepareGrid ()
 
 _prepareFilterButtons ()
 
 _beforeToHtml ()
 
- Protected Member Functions inherited from Widget
 _addBreadcrumb ($label, $title=null, $link=null)
 
- Protected Member Functions inherited from Template
 _toHtml ()
 
- Protected Member Functions inherited from Template
 _construct ()
 
 _toHtml ()
 
 getRootDirectory ()
 
 getMediaDirectory ()
 
- Protected Member Functions inherited from AbstractBlock
 _construct ()
 
 _prepareLayout ()
 
 _beforeToHtml ()
 
 _afterToHtml ($html)
 
 _toHtml ()
 
 _getNotFoundUrl ($route='', $params=['_direct'=> 'core/index/notFound'])
 
 getCacheTags ()
 
 getCacheLifetime ()
 
 _loadCache ()
 
 _saveCache ($data)
 
 _getSidPlaceholder ($cacheKey=null)
 
- Protected Member Functions inherited from DataObject
 _getData ($key)
 
 _underscore ($name)
 

Protected Attributes

 $_columns = []
 
 $_collection
 
 $_isExport = false
 
 $_exportTypes = []
 
 $_exportPageSize = 1000
 
 $_lastColumnId
 
 $_massactionIdField
 
 $_massactionIdFilter
 
 $_massactionBlockName = \Magento\Backend\Block\Widget\Grid\Massaction\Extended::class
 
 $_columnsOrder = []
 
 $_emptyCellLabel = ''
 
 $_groupedColumn = []
 
 $_headersVisibility = true
 
 $_filterVisibility = true
 
 $_emptyText
 
 $_emptyTextCss = 'empty-text'
 
 $_isCollapsed
 
 $_countSubTotals = false
 
 $_subtotals = []
 
 $_template = 'Magento_Backend::widget/grid/extended.phtml'
 
 $_directory
 
 $_path = 'export'
 
- Protected Attributes inherited from Grid
 $_varNameLimit = 'limit'
 
 $_varNamePage = 'page'
 
 $_varNameSort = 'sort'
 
 $_varNameDir = 'dir'
 
 $_varNameFilter = 'filter'
 
 $_defaultLimit = 20
 
 $_defaultPage = 1
 
 $_defaultSort = false
 
 $_defaultDir = 'desc'
 
 $_defaultFilter = []
 
 $_emptyText
 
 $_emptyTextCss = 'empty-text'
 
 $_pagerVisibility = true
 
 $_messageBlockVisibility = false
 
 $_saveParametersInSession = false
 
 $_countTotals = false
 
 $_varTotals
 
 $_template = 'Magento_Backend::widget/grid.phtml'
 
 $_backendSession
 
 $_backendHelper
 
- Protected Attributes inherited from Template
 $_authorization
 
 $mathRandom
 
 $_backendSession
 
 $formKey
 
 $nameBuilder
 
- Protected Attributes inherited from Template
 $_viewVars = []
 
 $_baseUrl
 
 $_jsUrl
 
 $_allowSymlinks
 
 $_filesystem
 
 $_template
 
 $templateEnginePool
 
 $_storeManager
 
 $_appState
 
 $directory
 
 $templateContext
 
 $pageConfig
 
 $resolver
 
 $validator
 
- Protected Attributes inherited from AbstractBlock
 $_design
 
 $_session
 
 $_sidResolver
 
 $_nameInLayout
 
 $_layout
 
 $jsLayout = []
 
 $_request
 
 $_urlBuilder
 
 $_eventManager
 
 $_frontController
 
 $_assetRepo
 
 $_viewConfig
 
 $_cacheState
 
 $_logger
 
 $_escaper
 
 $filterManager
 
 $_localeDate
 
 $inlineTranslation
 
 $_isScopePrivate = false
 
 $_scopeConfig
 
 $_cache
 
- Protected Attributes inherited from DataObject
 $_data = []
 

Additional Inherited Members

- Static Public Member Functions inherited from AbstractBlock
static extractModuleName ($className)
 
- Data Fields inherited from Template
const XML_PATH_TEMPLATE_ALLOW_SYMLINK = 'dev/template/allow_symlink'
 
- Data Fields inherited from AbstractBlock
const CACHE_GROUP = \Magento\Framework\App\Cache\Type\Block::TYPE_IDENTIFIER
 
const CACHE_KEY_PREFIX = 'BLOCK_'
 
- Static Protected Attributes inherited from DataObject
static $_underscoreCache = []
 

Detailed Description

@api

Deprecated:
100.2.0 in favour of UI component implementation @SuppressWarnings(PHPMD.ExcessivePublicCount) @SuppressWarnings(PHPMD.TooManyFields) @SuppressWarnings(PHPMD.ExcessiveClassComplexity) @SuppressWarnings(PHPMD.NumberOfChildren) @SuppressWarnings(PHPMD.CouplingBetweenObjects)
Since
100.0.2

Definition at line 20 of file Extended.php.

Member Function Documentation

◆ _afterLoadCollection()

_afterLoadCollection ( )
protected

Process collection after loading

Returns
$this

Definition at line 494 of file Extended.php.

495  {
496  return $this;
497  }

◆ _construct()

_construct ( )
protected
Returns
void

Definition at line 182 of file Extended.php.

183  {
184  parent::_construct();
185  $this->_emptyText = __('We couldn\'t find any records.');
186 
187  $this->_directory = $this->_filesystem->getDirectoryWrite(DirectoryList::VAR_DIR);
188  }
__()
Definition: __.php:13

◆ _exportCsvItem()

_exportCsvItem ( \Magento\Framework\DataObject  $item,
\Magento\Framework\Filesystem\File\WriteInterface  $stream 
)
protected

Write item data to csv export file

Parameters
\Magento\Framework\DataObject$item
\Magento\Framework\Filesystem\File\WriteInterface$stream
Returns
void

Definition at line 987 of file Extended.php.

990  {
991  $row = [];
992  foreach ($this->getColumns() as $column) {
993  if (!$column->getIsSystem()) {
994  $row[] = $column->getRowFieldExport($item);
995  }
996  }
997  $stream->writeCsv($row);
998  }

◆ _exportIterateCollection()

_exportIterateCollection (   $callback,
array  $args 
)

Iterate collection and call callback method per item For callback method first argument always is item object

Parameters
string$callback
array$argsadditional arguments for callback method
Returns
void

Definition at line 952 of file Extended.php.

953  {
954  $originalCollection = $this->getCollection();
955  $count = null;
956  $page = 1;
957  $lPage = null;
958  $break = false;
959 
960  while ($break !== true) {
961  $collection = clone $originalCollection;
962  $collection->setPageSize($this->_exportPageSize);
963  $collection->setCurPage($page);
964  $collection->load();
965  if ($count === null) {
966  $count = $collection->getSize();
967  $lPage = $collection->getLastPageNumber();
968  }
969  if ($lPage == $page) {
970  $break = true;
971  }
972  $page++;
973 
974  foreach ($collection as $item) {
975  call_user_func_array([$this, $callback], array_merge([$item], $args));
976  }
977  }
978  }
$count
Definition: recent.phtml:13
$page
Definition: pages.php:8

◆ _getExportHeaders()

_getExportHeaders ( )
protected

Retrieve Headers row array for Export

Returns
string[]

Definition at line 916 of file Extended.php.

917  {
918  $row = [];
919  foreach ($this->getColumns() as $column) {
920  if (!$column->getIsSystem()) {
921  $row[] = $column->getExportHeader();
922  }
923  }
924  return $row;
925  }

◆ _getExportTotals()

_getExportTotals ( )
protected

Retrieve Totals row array for Export

Returns
string[]

Definition at line 932 of file Extended.php.

933  {
934  $totals = $this->getTotals();
935  $row = [];
936  foreach ($this->getColumns() as $column) {
937  if (!$column->getIsSystem()) {
938  $row[] = $column->hasTotalsLabel() ? $column->getTotalsLabel() : $column->getRowFieldExport($totals);
939  }
940  }
941  return $row;
942  }
$totals
Definition: totalbar.phtml:10

◆ _getFileContainerContent()

_getFileContainerContent ( array  $fileData)
protected

Retrieve file content from file container array

Parameters
array$fileData
Returns
string

Definition at line 906 of file Extended.php.

907  {
908  return $this->_directory->readFile('export/' . $fileData['value']);
909  }

◆ _prepareCollection()

_prepareCollection ( )
protected

Apply sorting and filtering to collection

Returns
$this

Definition at line 471 of file Extended.php.

472  {
473  if ($this->getCollection()) {
474  if ($this->getCollection()->isLoaded()) {
475  $this->getCollection()->clear();
476  }
477 
478  parent::_prepareCollection();
479 
480  if (!$this->_isExport) {
481  $this->getCollection()->load();
482  $this->_afterLoadCollection();
483  }
484  }
485 
486  return $this;
487  }

◆ _prepareColumns()

_prepareColumns ( )
protected

Initialize grid columns

Returns
$this

Definition at line 398 of file Extended.php.

399  {
400  $this->sortColumnsByOrder();
401  return $this;
402  }

◆ _prepareGrid()

_prepareGrid ( )
protected

Initialize grid before rendering

Returns
$this

Definition at line 504 of file Extended.php.

505  {
506  $this->_prepareColumns();
507  $this->_prepareMassactionBlock();
508  parent::_prepareGrid();
509  return $this;
510  }

◆ _prepareLayout()

_prepareLayout ( )
protected

Initialize child blocks

Returns
$this

Definition at line 195 of file Extended.php.

196  {
197  $this->setChild(
198  'export_button',
199  $this->getLayout()->createBlock(\Magento\Backend\Block\Widget\Button::class)->setData(
200  [
201  'label' => __('Export'),
202  'onclick' => $this->getJsObjectName() . '.doExport()',
203  'class' => 'task',
204  ]
205  )
206  );
207  $this->setChild(
208  'reset_filter_button',
209  $this->getLayout()->createBlock(\Magento\Backend\Block\Widget\Button::class)->setData(
210  [
211  'label' => __('Reset Filter'),
212  'onclick' => $this->getJsObjectName() . '.resetFilter()',
213  'class' => 'action-reset action-tertiary'
214  ]
215  )->setDataAttribute(
216  [
217  'action' => 'grid-filter-reset'
218  ]
219  )
220  );
221  $this->setChild(
222  'search_button',
223  $this->getLayout()->createBlock(\Magento\Backend\Block\Widget\Button::class)->setData(
224  [
225  'label' => __('Search'),
226  'onclick' => $this->getJsObjectName() . '.doFilter()',
227  'class' => 'task action-secondary',
228  ]
229  )->setDataAttribute(
230  [
231  'action' => 'grid-filter-apply'
232  ]
233  )
234  );
235  return parent::_prepareLayout();
236  }
__()
Definition: __.php:13
setData($key, $value=null)
Definition: DataObject.php:72

◆ _prepareMassaction()

_prepareMassaction ( )
protected

Prepare grid massaction actions

Returns
$this

Definition at line 424 of file Extended.php.

425  {
426  return $this;
427  }

◆ _prepareMassactionBlock()

_prepareMassactionBlock ( )
protected

Prepare grid massaction block

Returns
$this

Definition at line 409 of file Extended.php.

410  {
411  $this->setChild('massaction', $this->getLayout()->createBlock($this->getMassactionBlockName()));
412  $this->_prepareMassaction();
413  if ($this->getMassactionBlock()->isAvailable()) {
414  $this->_prepareMassactionColumn();
415  }
416  return $this;
417  }

◆ _prepareMassactionColumn()

_prepareMassactionColumn ( )
protected

Prepare grid massaction column

Returns
$this

Definition at line 434 of file Extended.php.

435  {
436  $columnId = 'massaction';
437  $massactionColumn = $this->getLayout()
438  ->createBlock(\Magento\Backend\Block\Widget\Grid\Column::class)
439  ->setData(
440  [
441  'index' => $this->getMassactionIdField(),
442  'filter_index' => $this->getMassactionIdFilter(),
443  'type' => 'massaction',
444  'name' => $this->getMassactionBlock()->getFormFieldName(),
445  'is_system' => true,
446  'header_css_class' => 'col-select',
447  'column_css_class' => 'col-select',
448  ]
449  );
450 
451  if ($this->getNoFilterMassactionColumn()) {
452  $massactionColumn->setData('filter', false);
453  }
454 
455  $massactionColumn->setSelected($this->getMassactionBlock()->getSelected())->setGrid($this)->setId($columnId);
456 
457  $this->getColumnSet()->insert(
458  $massactionColumn,
459  count($this->getColumnSet()->getColumns()) + 1,
460  false,
461  $columnId
462  );
463  return $this;
464  }

◆ addColumn()

addColumn (   $columnId,
  $column 
)

Add column to grid

Parameters
string$columnId
array | \Magento\Framework\DataObject$column
Returns
$this
Exceptions

Definition at line 287 of file Extended.php.

288  {
289  if (is_array($column)) {
290  $this->getColumnSet()->setChild(
291  $columnId,
292  $this->getLayout()
293  ->createBlock(\Magento\Backend\Block\Widget\Grid\Column\Extended::class)
294  ->setData($column)
295  ->setId($columnId)
296  ->setGrid($this)
297  );
298  $this->getColumnSet()->getChildBlock($columnId)->setGrid($this);
299  } else {
300  throw new \Exception(__('Please correct the column format and try again.'));
301  }
302 
303  $this->_lastColumnId = $columnId;
304  return $this;
305  }
__()
Definition: __.php:13
setData($key, $value=null)
Definition: DataObject.php:72

◆ addColumnAfter()

addColumnAfter (   $columnId,
  $column,
  $after 
)

Add column to grid after specified column.

Parameters
string$columnId
array | \Magento\Framework\DataObject$column
string$after
Returns
$this

Definition at line 333 of file Extended.php.

334  {
335  $this->addColumn($columnId, $column);
336  $this->addColumnsOrder($columnId, $after);
337  return $this;
338  }

◆ addColumnsOrder()

addColumnsOrder (   $columnId,
  $after 
)

Add column view order

Parameters
string$columnId
string$after
Returns
$this

Definition at line 347 of file Extended.php.

348  {
349  $this->_columnsOrder[$columnId] = $after;
350  return $this;
351  }

◆ addExportType()

addExportType (   $url,
  $label 
)

Add new export type to grid

Parameters
string$url
string$label
Returns
$this

Implements ExportInterface.

Definition at line 271 of file Extended.php.

272  {
273  $this->_exportTypes[] = new \Magento\Framework\DataObject(
274  ['url' => $this->getUrl($url, ['_current' => true]), 'label' => $label]
275  );
276  return $this;
277  }
$label
Definition: details.phtml:21

◆ getCollection()

getCollection ( )

get collection object

Returns
\Magento\Framework\Data\Collection

Definition at line 1251 of file Extended.php.

1252  {
1253  return $this->_collection;
1254  }

◆ getColumnCount()

getColumnCount ( )

Count columns

Returns
int

Definition at line 784 of file Extended.php.

785  {
786  return count($this->getColumns());
787  }

◆ getColumnSet()

getColumnSet ( )

Retrieve column set block

Returns
\Magento\Framework\View\Element\AbstractBlock

Definition at line 243 of file Extended.php.

244  {
245  if (!$this->getChildBlock('grid.columnSet')) {
246  $this->setChild(
247  'grid.columnSet',
248  $this->getLayout()->createBlock(\Magento\Backend\Block\Widget\Grid\ColumnSet::class)
249  );
250  }
251  return parent::getColumnSet();
252  }

◆ getColumnsOrder()

getColumnsOrder ( )

Retrieve columns order

Returns
array

Definition at line 358 of file Extended.php.

◆ getCountSubTotals()

getCountSubTotals ( )

Return count subtotals

Returns
boolean @SuppressWarnings(PHPMD.BooleanGetMethodName)

Definition at line 1274 of file Extended.php.

◆ getCsv()

getCsv ( )

Retrieve Grid data as CSV

Returns
string

Implements ExportInterface.

Definition at line 1041 of file Extended.php.

1042  {
1043  $csv = '';
1044  $this->_isExport = true;
1045  $this->_prepareGrid();
1046  $this->getCollection()->getSelect()->limit();
1047  $this->getCollection()->setPageSize(0);
1048  $this->getCollection()->load();
1049  $this->_afterLoadCollection();
1050 
1051  $data = [];
1052  foreach ($this->getColumns() as $column) {
1053  if (!$column->getIsSystem()) {
1054  $data[] = '"' . $column->getExportHeader() . '"';
1055  }
1056  }
1057  $csv .= implode(',', $data) . "\n";
1058 
1059  foreach ($this->getCollection() as $item) {
1060  $data = [];
1061  foreach ($this->getColumns() as $column) {
1062  if (!$column->getIsSystem()) {
1063  $data[] = '"' . str_replace(
1064  ['"', '\\'],
1065  ['""', '\\\\'],
1066  $column->getRowFieldExport($item)
1067  ) . '"';
1068  }
1069  }
1070  $csv .= implode(',', $data) . "\n";
1071  }
1072 
1073  if ($this->getCountTotals()) {
1074  $data = [];
1075  foreach ($this->getColumns() as $column) {
1076  if (!$column->getIsSystem()) {
1077  $data[] = '"' . str_replace(
1078  ['"', '\\'],
1079  ['""', '\\\\'],
1080  $column->getRowFieldExport($this->getTotals())
1081  ) . '"';
1082  }
1083  }
1084  $csv .= implode(',', $data) . "\n";
1085  }
1086 
1087  return $csv;
1088  }

◆ getCsvFile()

getCsvFile ( )

Retrieve a file container array by grid data as CSV

Return array with keys type and value

Returns
array

Implements ExportInterface.

Definition at line 1007 of file Extended.php.

1008  {
1009  $this->_isExport = true;
1010  $this->_prepareGrid();
1011 
1012  $name = md5(microtime());
1013  $file = $this->_path . '/' . $name . '.csv';
1014 
1015  $this->_directory->create($this->_path);
1016  $stream = $this->_directory->openFile($file, 'w+');
1017 
1018  $stream->lock();
1019  $stream->writeCsv($this->_getExportHeaders());
1020  $this->_exportIterateCollection('_exportCsvItem', [$stream]);
1021 
1022  if ($this->getCountTotals()) {
1023  $stream->writeCsv($this->_getExportTotals());
1024  }
1025 
1026  $stream->unlock();
1027  $stream->close();
1028 
1029  return [
1030  'type' => 'filename',
1031  'value' => $file,
1032  'rm' => true // can delete file after use
1033  ];
1034  }
_exportIterateCollection($callback, array $args)
Definition: Extended.php:952
if(!isset($_GET['name'])) $name
Definition: log.php:14

◆ getEmptyCellColspan()

getEmptyCellColspan ( )

Retrieve colspan for empty cell

Returns
int

Definition at line 756 of file Extended.php.

757  {
758  return $this->getColumnCount() - count($this->_groupedColumn);
759  }

◆ getEmptyCellLabel()

getEmptyCellLabel ( )

Retrieve label for empty cell

Returns
string

Definition at line 641 of file Extended.php.

◆ getEmptyText()

getEmptyText ( )

Return empty text for grid

Returns
string

Definition at line 850 of file Extended.php.

◆ getEmptyTextClass()

getEmptyTextClass ( )

Return empty text CSS class

Returns
string

Definition at line 872 of file Extended.php.

◆ getExcel()

getExcel ( )

Retrieve grid data as MS Excel 2003 XML Document

Returns
string

Implements ExportInterface.

Definition at line 1184 of file Extended.php.

1185  {
1186  $this->_isExport = true;
1187  $this->_prepareGrid();
1188  $this->getCollection()->getSelect()->limit();
1189  $this->getCollection()->setPageSize(0);
1190  $this->getCollection()->load();
1191  $this->_afterLoadCollection();
1192  $headers = [];
1193  $data = [];
1194  foreach ($this->getColumns() as $column) {
1195  if (!$column->getIsSystem()) {
1196  $headers[] = $column->getHeader();
1197  }
1198  }
1199  $data[] = $headers;
1200 
1201  foreach ($this->getCollection() as $item) {
1202  $row = [];
1203  foreach ($this->getColumns() as $column) {
1204  if (!$column->getIsSystem()) {
1205  $row[] = $column->getRowField($item);
1206  }
1207  }
1208  $data[] = $row;
1209  }
1210 
1211  if ($this->getCountTotals()) {
1212  $row = [];
1213  foreach ($this->getColumns() as $column) {
1214  if (!$column->getIsSystem()) {
1215  $row[] = $column->getRowField($this->getTotals());
1216  }
1217  }
1218  $data[] = $row;
1219  }
1220 
1221  $convert = new \Magento\Framework\Convert\Excel(new \ArrayIterator($data));
1222  return $convert->convert('single_sheet');
1223  }

◆ getExcelFile()

getExcelFile (   $sheetName = '')

Retrieve a file container array by grid data as MS Excel 2003 XML Document

Return array with keys type and value

Parameters
string$sheetName
Returns
array

Implements ExportInterface.

Definition at line 1146 of file Extended.php.

1147  {
1148  $this->_isExport = true;
1149  $this->_prepareGrid();
1150 
1151  $convert = new \Magento\Framework\Convert\Excel(
1152  $this->getCollection()->getIterator(),
1153  [$this, 'getRowRecord']
1154  );
1155 
1156  $name = md5(microtime());
1157  $file = $this->_path . '/' . $name . '.xml';
1158 
1159  $this->_directory->create($this->_path);
1160  $stream = $this->_directory->openFile($file, 'w+');
1161  $stream->lock();
1162 
1163  $convert->setDataHeader($this->_getExportHeaders());
1164  if ($this->getCountTotals()) {
1165  $convert->setDataFooter($this->_getExportTotals());
1166  }
1167 
1168  $convert->write($stream, $sheetName);
1169  $stream->unlock();
1170  $stream->close();
1171 
1172  return [
1173  'type' => 'filename',
1174  'value' => $file,
1175  'rm' => true // can delete file after use
1176  ];
1177  }
if(!isset($_GET['name'])) $name
Definition: log.php:14

◆ getExportButtonHtml()

getExportButtonHtml ( )

Generate export button

Returns
string

Implements ExportInterface.

Definition at line 259 of file Extended.php.

260  {
261  return $this->getChildHtml('export_button');
262  }

◆ getExportTypes()

getExportTypes ( )

Retrieve grid export types

Returns
\Magento\Framework\DataObject[]|false

Implements ExportInterface.

Definition at line 1230 of file Extended.php.

1231  {
1232  return empty($this->_exportTypes) ? false : $this->_exportTypes;
1233  }
return false
Definition: gallery.phtml:36

◆ getFilterVisibility()

getFilterVisibility ( )

Return visibility of filter

Returns
boolean @SuppressWarnings(PHPMD.BooleanGetMethodName)

Definition at line 828 of file Extended.php.

◆ getHeadersVisibility()

getHeadersVisibility ( )

Return visibility of column headers

Returns
boolean @SuppressWarnings(PHPMD.BooleanGetMethodName)

Definition at line 806 of file Extended.php.

◆ getHtml()

getHtml ( )

Retrieve grid HTML

Returns
string

Definition at line 517 of file Extended.php.

518  {
519  return $this->toHtml();
520  }

◆ getIsCollapsed()

getIsCollapsed ( )

Retrieve flag is collapsed

Returns
bool @SuppressWarnings(PHPMD.BooleanGetMethodName)

Definition at line 895 of file Extended.php.

◆ getLastColumnId()

getLastColumnId ( )

Retrieve identifier of last column

Returns
string

Definition at line 388 of file Extended.php.

◆ getMainButtonsHtml()

getMainButtonsHtml ( )

Generate list of grid buttons

Returns
string

Definition at line 1306 of file Extended.php.

1307  {
1308  $html = '';
1309  if ($this->getFilterVisibility()) {
1310  $html .= $this->getSearchButtonHtml();
1311  $html .= $this->getResetFilterButtonHtml();
1312  }
1313  return $html;
1314  }

◆ getMassactionBlock()

getMassactionBlock ( )

Retrieve massaction block

Returns
$this

Definition at line 593 of file Extended.php.

594  {
595  return $this->getChildBlock('massaction');
596  }

◆ getMassactionBlockHtml()

getMassactionBlockHtml ( )

Generate massaction block

Returns
string

Definition at line 603 of file Extended.php.

604  {
605  return $this->getChildHtml('massaction');
606  }

◆ getMassactionBlockName()

getMassactionBlockName ( )

Retrieve massaction block name

Returns
string

Definition at line 571 of file Extended.php.

◆ getMassactionIdField()

getMassactionIdField ( )

Retrieve massaction row identifier field

Returns
string

Definition at line 527 of file Extended.php.

◆ getMassactionIdFilter()

getMassactionIdFilter ( )

Retrieve massaction row identifier filter

Returns
string

Definition at line 549 of file Extended.php.

◆ getMultipleRowColumns()

getMultipleRowColumns ( )

Retrieve columns for multiple rows

Returns
array

Definition at line 685 of file Extended.php.

686  {
687  $columns = $this->getColumns();
688  foreach ($this->_groupedColumn as $column) {
689  unset($columns[$column]);
690  }
691  return $columns;
692  }
$columns
Definition: default.phtml:15

◆ getMultipleRows()

getMultipleRows (   $item)

Get children of specified item

Parameters
\Magento\Framework\DataObject$item
Returns
array

Definition at line 676 of file Extended.php.

677  {
678  return $item->getChildren();
679  }

◆ getRowRecord()

getRowRecord ( \Magento\Framework\DataObject  $data)

Get a row data of the particular columns

Parameters
\Magento\Framework\DataObject$data
Returns
string[]

Definition at line 1127 of file Extended.php.

1128  {
1129  $row = [];
1130  foreach ($this->getColumns() as $column) {
1131  if (!$column->getIsSystem()) {
1132  $row[] = $column->getRowFieldExport($data);
1133  }
1134  }
1135  return $row;
1136  }

◆ getRowspan()

getRowspan (   $item,
  $column 
)

Retrieve rowspan number

Parameters
\Magento\Framework\DataObject$item
\Magento\Backend\Block\Widget\Grid\Column$column
Returns
int|false

Definition at line 712 of file Extended.php.

713  {
714  if ($this->isColumnGrouped($column)) {
715  return count($this->getMultipleRows($item)) + count($this->_groupedColumn);
716  }
717  return false;
718  }

◆ getRowUrl()

getRowUrl (   $item)

Return row url for js event handlers

Parameters
\Magento\Catalog\Model\Product | \Magento\Framework\DataObject$item
Returns
string

Definition at line 664 of file Extended.php.

665  {
666  $res = parent::getRowUrl($item);
667  return $res ? $res : '#';
668  }

◆ getSubTotalColumns()

getSubTotalColumns ( )

Retrieve columns to render

Returns
array

Definition at line 613 of file Extended.php.

614  {
615  return $this->getColumns();
616  }

◆ getSubTotalItem()

getSubTotalItem (   $item)

Retrieve subtotal item

Parameters
\Magento\Framework\DataObject$item
Returns
\Magento\Framework\DataObject|string

Definition at line 767 of file Extended.php.

768  {
769  foreach ($this->_subtotals as $subtotalItem) {
770  foreach ($this->_groupedColumn as $groupedColumn) {
771  if ($subtotalItem->getData($groupedColumn) == $item->getData($groupedColumn)) {
772  return $subtotalItem;
773  }
774  }
775  }
776  return '';
777  }

◆ getSubTotals()

getSubTotals ( )

Retrieve subtotal items

Returns
\Magento\Framework\DataObject[]

Definition at line 1296 of file Extended.php.

1297  {
1298  return $this->_subtotals;
1299  }

◆ getXml()

getXml ( )

Retrieve data in xml

Returns
string

Implements ExportInterface.

Definition at line 1095 of file Extended.php.

1096  {
1097  $this->_isExport = true;
1098  $this->_prepareGrid();
1099  $this->getCollection()->getSelect()->limit();
1100  $this->getCollection()->setPageSize(0);
1101  $this->getCollection()->load();
1102  $this->_afterLoadCollection();
1103  $indexes = [];
1104  foreach ($this->getColumns() as $column) {
1105  if (!$column->getIsSystem()) {
1106  $indexes[] = $column->getIndex();
1107  }
1108  }
1109  $xml = '<?xml version="1.0" encoding="UTF-8"?>';
1110  $xml .= '<items>';
1111  foreach ($this->getCollection() as $item) {
1112  $xml .= $item->toXml($indexes);
1113  }
1114  if ($this->getCountTotals()) {
1115  $xml .= $this->getTotals()->toXml($indexes);
1116  }
1117  $xml .= '</items>';
1118  return $xml;
1119  }

◆ isColumnGrouped()

isColumnGrouped (   $column,
  $value = null 
)

Check whether given column is grouped

Parameters
string | object$column
string$value
Returns
boolean|$this

Definition at line 727 of file Extended.php.

728  {
729  if (null === $value) {
730  if (is_object($column)) {
731  return in_array($column->getIndex(), $this->_groupedColumn);
732  }
733  return in_array($column, $this->_groupedColumn);
734  }
735  $this->_groupedColumn[] = $column;
736  return $this;
737  }
$value
Definition: gender.phtml:16

◆ removeColumn()

removeColumn (   $columnId)

Remove existing column

Parameters
string$columnId
Returns
$this

Definition at line 313 of file Extended.php.

314  {
315  if ($this->getColumnSet()->getChildBlock($columnId)) {
316  $this->getColumnSet()->unsetChild($columnId);
317  if ($this->_lastColumnId == $columnId) {
318  $names = $this->getColumnSet()->getChildNames();
319  $this->_lastColumnId = array_pop($names);
320  }
321  }
322  return $this;
323  }

◆ setCollection()

setCollection (   $collection)

Set collection object

Parameters
\Magento\Framework\Data\Collection$collection
Returns
void

Definition at line 1241 of file Extended.php.

1242  {
1243  $this->_collection = $collection;
1244  }
$this _collection
Definition: coupons.php:7

◆ setCountSubTotals()

setCountSubTotals (   $flag = true)

Set subtotals

Parameters
boolean$flag
Returns
$this

Definition at line 1262 of file Extended.php.

1263  {
1264  $this->_countSubTotals = $flag;
1265  return $this;
1266  }

◆ setEmptyCellLabel()

setEmptyCellLabel (   $label)

Set label for empty cell

Parameters
string$label
Returns
$this

Definition at line 652 of file Extended.php.

653  {
654  $this->_emptyCellLabel = $label;
655  return $this;
656  }
$label
Definition: details.phtml:21

◆ setEmptyText()

setEmptyText (   $text)

Set empty text for grid

Parameters
string$text
Returns
$this

Definition at line 839 of file Extended.php.

840  {
841  $this->_emptyText = $text;
842  return $this;
843  }
endifif( $block->getLastPageNum()>1)( 'Page') ?></strong >< ul class $text
Definition: pager.phtml:43

◆ setEmptyTextClass()

setEmptyTextClass (   $cssClass)

Set empty text CSS class

Parameters
string$cssClass
Returns
$this

Definition at line 861 of file Extended.php.

862  {
863  $this->_emptyTextCss = $cssClass;
864  return $this;
865  }
if(!isset($advancedLabel)) $cssClass
Definition: fieldset.phtml:25

◆ setFilterVisibility()

setFilterVisibility (   $visible = true)

Set visibility of filter

Parameters
bool$visible
Returns
void

Definition at line 817 of file Extended.php.

818  {
819  $this->_filterVisibility = $visible;
820  }

◆ setHeadersVisibility()

setHeadersVisibility (   $visible = true)

Set visibility of column headers

Parameters
bool$visible
Returns
void

Definition at line 795 of file Extended.php.

796  {
797  $this->_headersVisibility = $visible;
798  }

◆ setIsCollapsed()

setIsCollapsed (   $isCollapsed)

Set flag whether is collapsed

Parameters
bool$isCollapsed
Returns
$this

Definition at line 883 of file Extended.php.

884  {
885  $this->_isCollapsed = $isCollapsed;
886  return $this;
887  }

◆ setMassactionBlockName()

setMassactionBlockName (   $blockName)

Set massaction block name

Parameters
string$blockName
Returns
$this

Definition at line 582 of file Extended.php.

583  {
584  $this->_massactionBlockName = $blockName;
585  return $this;
586  }

◆ setMassactionIdField()

setMassactionIdField (   $idField)

Set massaction row identifier field

Parameters
string$idField
Returns
$this

Definition at line 538 of file Extended.php.

539  {
540  $this->_massactionIdField = $idField;
541  return $this;
542  }

◆ setMassactionIdFilter()

setMassactionIdFilter (   $idFilter)

Set massaction row identifier filter

Parameters
string$idFilter
Returns
$this

Definition at line 560 of file Extended.php.

561  {
562  $this->_massactionIdFilter = $idFilter;
563  return $this;
564  }

◆ setSubTotals()

setSubTotals ( array  $items)

Set subtotal items

Parameters

Definition at line 1285 of file Extended.php.

1286  {
1287  $this->_subtotals = $items;
1288  return $this;
1289  }
$items

◆ shouldRenderCell()

shouldRenderCell (   $item,
  $column 
)

Check whether should render cell

Parameters
\Magento\Framework\DataObject$item
\Magento\Backend\Block\Widget\Grid\Column$column
Returns
boolean

Definition at line 625 of file Extended.php.

626  {
627  if ($this->isColumnGrouped($column) && $item->getIsEmpty()) {
628  return true;
629  }
630  if (!$item->getIsEmpty()) {
631  return true;
632  }
633  return false;
634  }

◆ shouldRenderEmptyCell()

shouldRenderEmptyCell (   $item,
  $column 
)

Check whether should render empty cell

Parameters
\Magento\Framework\DataObject$item
\Magento\Backend\Block\Widget\Grid\Column$column
Returns
boolean

Definition at line 746 of file Extended.php.

747  {
748  return $item->getIsEmpty() && in_array($column['index'], $this->_groupedColumn);
749  }

◆ shouldRenderSubTotal()

shouldRenderSubTotal (   $item)

Check whether subtotal should be rendered

Parameters
\Magento\Framework\DataObject$item
Returns
boolean

Definition at line 700 of file Extended.php.

701  {
702  return $this->_countSubTotals && count($this->_subtotals) > 0 && count($this->getMultipleRows($item)) > 0;
703  }

◆ sortColumnsByOrder()

sortColumnsByOrder ( )

Sort columns by predefined order

Returns
$this

Definition at line 368 of file Extended.php.

369  {
370  foreach ($this->getColumnsOrder() as $columnId => $after) {
371  $this->getLayout()->reorderChild(
372  $this->getColumnSet()->getNameInLayout(),
373  $this->getColumn($columnId)->getNameInLayout(),
374  $this->getColumn($after)->getNameInLayout()
375  );
376  }
377 
378  $columns = $this->getColumnSet()->getChildNames();
379  $this->_lastColumnId = array_pop($columns);
380  return $this;
381  }
$columns
Definition: default.phtml:15

Field Documentation

◆ $_collection

$_collection
protected

Definition at line 43 of file Extended.php.

◆ $_columns

$_columns = []
protected

Definition at line 36 of file Extended.php.

◆ $_columnsOrder

$_columnsOrder = []
protected

Definition at line 99 of file Extended.php.

◆ $_countSubTotals

$_countSubTotals = false
protected

Definition at line 153 of file Extended.php.

◆ $_directory

$_directory
protected

Definition at line 170 of file Extended.php.

◆ $_emptyCellLabel

$_emptyCellLabel = ''
protected

Definition at line 106 of file Extended.php.

◆ $_emptyText

$_emptyText
protected

Definition at line 134 of file Extended.php.

◆ $_emptyTextCss

$_emptyTextCss = 'empty-text'
protected

Definition at line 141 of file Extended.php.

◆ $_exportPageSize

$_exportPageSize = 1000
protected

Definition at line 64 of file Extended.php.

◆ $_exportTypes

$_exportTypes = []
protected

Definition at line 57 of file Extended.php.

◆ $_filterVisibility

$_filterVisibility = true
protected

Definition at line 127 of file Extended.php.

◆ $_groupedColumn

$_groupedColumn = []
protected

Definition at line 113 of file Extended.php.

◆ $_headersVisibility

$_headersVisibility = true
protected

Definition at line 120 of file Extended.php.

◆ $_isCollapsed

$_isCollapsed
protected

Definition at line 146 of file Extended.php.

◆ $_isExport

$_isExport = false
protected

Definition at line 50 of file Extended.php.

◆ $_lastColumnId

$_lastColumnId
protected

Definition at line 71 of file Extended.php.

◆ $_massactionBlockName

$_massactionBlockName = \Magento\Backend\Block\Widget\Grid\Massaction\Extended::class
protected

Definition at line 92 of file Extended.php.

◆ $_massactionIdField

$_massactionIdField
protected

Definition at line 78 of file Extended.php.

◆ $_massactionIdFilter

$_massactionIdFilter
protected

Definition at line 85 of file Extended.php.

◆ $_path

$_path = 'export'
protected

Definition at line 177 of file Extended.php.

◆ $_subtotals

$_subtotals = []
protected

Definition at line 160 of file Extended.php.

◆ $_template

$_template = 'Magento_Backend::widget/grid/extended.phtml'
protected

Definition at line 165 of file Extended.php.


The documentation for this class was generated from the following file: