forked from magento/magento2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGrid.php
More file actions
167 lines (153 loc) · 4.93 KB
/
Grid.php
File metadata and controls
167 lines (153 loc) · 4.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Review\Block\Adminhtml\Product;
/**
* Adminhtml product grid block
*
* @SuppressWarnings(PHPMD.DepthOfInheritance)
*/
class Grid extends \Magento\Catalog\Block\Adminhtml\Product\Grid
{
/**
* Website collection
*
* @var \Magento\Store\Model\ResourceModel\Website\CollectionFactory
*/
protected $_websitesFactory;
/**
* @param \Magento\Backend\Block\Template\Context $context
* @param \Magento\Backend\Helper\Data $backendHelper
* @param \Magento\Store\Model\WebsiteFactory $websiteFactory
* @param \Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\CollectionFactory $setsFactory
* @param \Magento\Catalog\Model\ProductFactory $productFactory
* @param \Magento\Catalog\Model\Product\Type $type
* @param \Magento\Catalog\Model\Product\Attribute\Source\Status $status
* @param \Magento\Catalog\Model\Product\Visibility $visibility
* @param \Magento\Framework\Module\Manager $moduleManager
* @param \Magento\Store\Model\ResourceModel\Website\CollectionFactory $websitesFactory
* @param array $data
*
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __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 = []
) {
$this->_websitesFactory = $websitesFactory;
parent::__construct(
$context,
$backendHelper,
$websiteFactory,
$setsFactory,
$productFactory,
$type,
$status,
$visibility,
$moduleManager,
$data
);
}
/**
* Initialize review
*
* @return void
*/
protected function _construct()
{
parent::_construct();
$this->setRowClickCallback('review.gridRowClick');
$this->setUseAjax(true);
}
/**
* Prepare product review grid
*
* @return void
*/
protected function _prepareColumns()
{
$this->addColumn(
'entity_id',
[
'header' => __('ID'),
'index' => 'entity_id',
'header_css_class' => 'col-id',
'column_css_class' => 'col-id'
]
);
$this->addColumn('name', ['header' => __('Name'), 'index' => 'name']);
if ((int)$this->getRequest()->getParam('store', 0)) {
$this->addColumn('custom_name', ['header' => __('Product Store Name'), 'index' => 'custom_name']);
}
$this->addColumn('sku', ['header' => __('SKU'), 'index' => 'sku']);
$this->addColumn('price', ['header' => __('Price'), 'type' => 'currency', 'index' => 'price']);
$this->addColumn(
'qty',
['header' => __('Quantity'), 'type' => 'number', 'index' => 'qty']
);
$this->addColumn(
'status',
[
'header' => __('Status'),
'index' => 'status',
'type' => 'options',
'source' => \Magento\Catalog\Model\Product\Attribute\Source\Status::class,
'options' => $this->_status->getOptionArray()
]
);
/**
* Check is single store mode
*/
if (!$this->_storeManager->isSingleStoreMode()) {
$this->addColumn(
'websites',
[
'header' => __('Websites'),
'sortable' => false,
'index' => 'websites',
'type' => 'options',
'options' => $this->_websitesFactory->create()->toOptionHash()
]
);
}
}
/**
* Get catalog product grid url
*
* @return string
*/
public function getGridUrl()
{
return $this->getUrl('review/product/productGrid', ['_current' => true]);
}
/**
* Get catalog product row url
*
* @param \Magento\Framework\DataObject $row
* @return string
*/
public function getRowUrl($row)
{
return $this->getUrl('review/product/jsonProductInfo', ['id' => $row->getId()]);
}
/**
* Prepare mass action
*
* @return $this
*/
protected function _prepareMassaction()
{
return $this;
}
}