1414use Magento \Backend \Block \Widget \Grid ;
1515use Magento \Backend \Block \Widget \Grid \Column ;
1616use Magento \Backend \Block \Widget \Grid \Extended ;
17+ use Magento \Catalog \Model \Product \Attribute \Source \Status ;
18+ use Magento \Catalog \Model \Product \Visibility ;
19+ use Magento \Framework \App \ObjectManager ;
1720
1821class Product extends \Magento \Backend \Block \Widget \Grid \Extended
1922{
@@ -29,22 +32,38 @@ class Product extends \Magento\Backend\Block\Widget\Grid\Extended
2932 */
3033 protected $ _productFactory ;
3134
35+ /**
36+ * @var Status
37+ */
38+ private $ status ;
39+
40+ /**
41+ * @var Visibility
42+ */
43+ private $ visibility ;
44+
3245 /**
3346 * @param \Magento\Backend\Block\Template\Context $context
3447 * @param \Magento\Backend\Helper\Data $backendHelper
3548 * @param \Magento\Catalog\Model\ProductFactory $productFactory
3649 * @param \Magento\Framework\Registry $coreRegistry
3750 * @param array $data
51+ * @param Visibility|null $visibility
52+ * @param Status|null $status
3853 */
3954 public function __construct (
4055 \Magento \Backend \Block \Template \Context $ context ,
4156 \Magento \Backend \Helper \Data $ backendHelper ,
4257 \Magento \Catalog \Model \ProductFactory $ productFactory ,
4358 \Magento \Framework \Registry $ coreRegistry ,
44- array $ data = []
59+ array $ data = [],
60+ Visibility $ visibility = null ,
61+ Status $ status = null
4562 ) {
4663 $ this ->_productFactory = $ productFactory ;
4764 $ this ->_coreRegistry = $ coreRegistry ;
65+ $ this ->visibility = $ visibility ?: ObjectManager::getInstance ()->get (Visibility::class);
66+ $ this ->status = $ status ?: ObjectManager::getInstance ()->get (Status::class);
4867 parent ::__construct ($ context , $ backendHelper , $ data );
4968 }
5069
@@ -102,6 +121,10 @@ protected function _prepareCollection()
102121 'name '
103122 )->addAttributeToSelect (
104123 'sku '
124+ )->addAttributeToSelect (
125+ 'visibility '
126+ )->addAttributeToSelect (
127+ 'status '
105128 )->addAttributeToSelect (
106129 'price '
107130 )->joinField (
@@ -159,6 +182,28 @@ protected function _prepareColumns()
159182 );
160183 $ this ->addColumn ('name ' , ['header ' => __ ('Name ' ), 'index ' => 'name ' ]);
161184 $ this ->addColumn ('sku ' , ['header ' => __ ('SKU ' ), 'index ' => 'sku ' ]);
185+ $ this ->addColumn (
186+ 'visibility ' ,
187+ [
188+ 'header ' => __ ('Visibility ' ),
189+ 'index ' => 'visibility ' ,
190+ 'type ' => 'options ' ,
191+ 'options ' => $ this ->visibility ->getOptionArray (),
192+ 'header_css_class ' => 'col-visibility ' ,
193+ 'column_css_class ' => 'col-visibility '
194+ ]
195+ );
196+
197+ $ this ->addColumn (
198+ 'status ' ,
199+ [
200+ 'header ' => __ ('Status ' ),
201+ 'index ' => 'status ' ,
202+ 'type ' => 'options ' ,
203+ 'options ' => $ this ->status ->getOptionArray ()
204+ ]
205+ );
206+
162207 $ this ->addColumn (
163208 'price ' ,
164209 [
0 commit comments