Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Grid.php
Go to the documentation of this file.
1 <?php
7 
14 class Grid extends \Magento\Catalog\Block\Adminhtml\Product\Grid
15 {
21  protected $_websitesFactory;
22 
38  public function __construct(
39  \Magento\Backend\Block\Template\Context $context,
40  \Magento\Backend\Helper\Data $backendHelper,
41  \Magento\Store\Model\WebsiteFactory $websiteFactory,
42  \Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\CollectionFactory $setsFactory,
43  \Magento\Catalog\Model\ProductFactory $productFactory,
44  \Magento\Catalog\Model\Product\Type $type,
45  \Magento\Catalog\Model\Product\Attribute\Source\Status $status,
46  \Magento\Catalog\Model\Product\Visibility $visibility,
47  \Magento\Framework\Module\Manager $moduleManager,
48  \Magento\Store\Model\ResourceModel\Website\CollectionFactory $websitesFactory,
49  array $data = []
50  ) {
51  $this->_websitesFactory = $websitesFactory;
52  parent::__construct(
53  $context,
54  $backendHelper,
55  $websiteFactory,
56  $setsFactory,
58  $type,
59  $status,
60  $visibility,
62  $data
63  );
64  }
65 
71  protected function _construct()
72  {
73  parent::_construct();
74  $this->setRowClickCallback('review.gridRowClick');
75  $this->setUseAjax(true);
76  }
77 
83  protected function _prepareColumns()
84  {
85  $this->addColumn(
86  'entity_id',
87  [
88  'header' => __('ID'),
89  'index' => 'entity_id',
90  'header_css_class' => 'col-id',
91  'column_css_class' => 'col-id'
92  ]
93  );
94 
95  $this->addColumn('name', ['header' => __('Name'), 'index' => 'name']);
96 
97  if ((int)$this->getRequest()->getParam('store', 0)) {
98  $this->addColumn('custom_name', ['header' => __('Product Store Name'), 'index' => 'custom_name']);
99  }
100 
101  $this->addColumn('sku', ['header' => __('SKU'), 'index' => 'sku']);
102 
103  $this->addColumn('price', ['header' => __('Price'), 'type' => 'currency', 'index' => 'price']);
104 
105  $this->addColumn(
106  'qty',
107  ['header' => __('Quantity'), 'type' => 'number', 'index' => 'qty']
108  );
109 
110  $this->addColumn(
111  'status',
112  [
113  'header' => __('Status'),
114  'index' => 'status',
115  'type' => 'options',
116  'source' => \Magento\Catalog\Model\Product\Attribute\Source\Status::class,
117  'options' => $this->_status->getOptionArray()
118  ]
119  );
120 
124  if (!$this->_storeManager->isSingleStoreMode()) {
125  $this->addColumn(
126  'websites',
127  [
128  'header' => __('Websites'),
129  'sortable' => false,
130  'index' => 'websites',
131  'type' => 'options',
132  'options' => $this->_websitesFactory->create()->toOptionHash()
133  ]
134  );
135  }
136  }
137 
143  public function getGridUrl()
144  {
145  return $this->getUrl('review/product/productGrid', ['_current' => true]);
146  }
147 
154  public function getRowUrl($row)
155  {
156  return $this->getUrl('review/product/jsonProductInfo', ['id' => $row->getId()]);
157  }
158 
164  protected function _prepareMassaction()
165  {
166  return $this;
167  }
168 }
__()
Definition: __.php:13
$type
Definition: item.phtml:13
__construct(\Magento\Backend\Block\Template\Context $context, \Magento\Backend\Helper\Data $backendHelper, \Magento\Store\Model\WebsiteFactory $websiteFactory, \Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\CollectionFactory $setsFactory, \Magento\Catalog\Model\ProductFactory $productFactory, \Magento\Catalog\Model\Product\Type $type, \Magento\Catalog\Model\Product\Attribute\Source\Status $status, \Magento\Catalog\Model\Product\Visibility $visibility, \Magento\Framework\Module\Manager $moduleManager, \Magento\Store\Model\ResourceModel\Website\CollectionFactory $websitesFactory, array $data=[])
Definition: Grid.php:38
$status
Definition: order_status.php:8
getParam($paramName, $default=null)
Definition: Grid.php:729