Skip to content

Commit 7ae8c6e

Browse files
author
joweecaquicla
committed
magento/adobe-stock-integration#1748: Some category grid columns are empty - fixed issue of empty columns and added column renderer for in menu and enabled columns
1 parent a360c06 commit 7ae8c6e

File tree

3 files changed

+74
-2
lines changed

3 files changed

+74
-2
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\MediaGalleryCatalogUi\Ui\Component\Listing\Columns;
7+
8+
use Magento\Ui\Component\Listing\Columns\Column;
9+
10+
/**
11+
* Class InMenu column for Category grid
12+
*/
13+
class InMenu extends Column
14+
{
15+
/**
16+
* Prepare data source.
17+
*
18+
* @param array $dataSource
19+
* @return array
20+
*/
21+
public function prepareDataSource(array $dataSource)
22+
{
23+
if (isset($dataSource['data']['items'])) {
24+
$fieldName = $this->getData('name');
25+
foreach ($dataSource['data']['items'] as & $item) {
26+
if (isset($item[$fieldName]) && $item[$fieldName] == 1) {
27+
$item[$fieldName] = 'Yes';
28+
} else {
29+
$item[$fieldName] = 'No';
30+
}
31+
}
32+
}
33+
34+
return $dataSource;
35+
}
36+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\MediaGalleryCatalogUi\Ui\Component\Listing\Columns;
7+
8+
use Magento\Ui\Component\Listing\Columns\Column;
9+
10+
/**
11+
* Class IsActive column for Category grid
12+
*/
13+
class IsActive extends Column
14+
{
15+
/**
16+
* Prepare data source.
17+
*
18+
* @param array $dataSource
19+
* @return array
20+
*/
21+
public function prepareDataSource(array $dataSource)
22+
{
23+
if (isset($dataSource['data']['items'])) {
24+
$fieldName = $this->getData('name');
25+
foreach ($dataSource['data']['items'] as & $item) {
26+
if (isset($item[$fieldName]) && $item[$fieldName] == 1) {
27+
$item[$fieldName] = 'Yes';
28+
} else {
29+
$item[$fieldName] = 'No';
30+
}
31+
}
32+
}
33+
34+
return $dataSource;
35+
}
36+
}

app/code/Magento/MediaGalleryCatalogUi/view/adminhtml/ui_component/media_gallery_category_listing.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,12 @@
167167
<label translate="true">Products</label>
168168
</settings>
169169
</column>
170-
<column name="include_in_menu" component="Magento_Ui/js/grid/columns/select">
170+
<column name="include_in_menu" class="Magento\MediaGalleryCatalogUi\Ui\Component\Listing\Columns\InMenu">
171171
<settings>
172172
<label translate="true">In Menu</label>
173173
</settings>
174174
</column>
175-
<column name="is_active" component="Magento_Ui/js/grid/columns/select" >
175+
<column name="is_active" class="Magento\MediaGalleryCatalogUi\Ui\Component\Listing\Columns\IsActive">
176176
<settings>
177177
<label translate="true">Enabled</label>
178178
</settings>

0 commit comments

Comments
 (0)