6
6
namespace Magento \MediaGalleryCatalogUi \Ui \Component \Listing \Columns ;
7
7
8
8
use Magento \Catalog \Helper \Image ;
9
- use Magento \Framework \ DataObject ;
9
+ use Magento \Catalog \ Model \ ProductFactory ;
10
10
use Magento \Framework \View \Element \UiComponent \ContextInterface ;
11
11
use Magento \Framework \View \Element \UiComponentFactory ;
12
12
use Magento \Store \Model \Store ;
@@ -29,11 +29,17 @@ class Thumbnail extends Column
29
29
*/
30
30
private $ imageHelper ;
31
31
32
+ /**
33
+ * @var ProductFactory
34
+ */
35
+ private $ productFactory ;
36
+
32
37
/**
33
38
* @param ContextInterface $context
34
39
* @param UiComponentFactory $uiComponentFactory
35
40
* @param StoreManagerInterface $storeManager
36
41
* @param Image $image
42
+ * @param ProductFactory $productFactory
37
43
* @param array $components
38
44
* @param array $data
39
45
*/
@@ -42,12 +48,14 @@ public function __construct(
42
48
UiComponentFactory $ uiComponentFactory ,
43
49
StoreManagerInterface $ storeManager ,
44
50
Image $ image ,
51
+ ProductFactory $ productFactory ,
45
52
array $ components = [],
46
53
array $ data = []
47
54
) {
48
55
parent ::__construct ($ context , $ uiComponentFactory , $ components , $ data );
49
56
$ this ->imageHelper = $ image ;
50
57
$ this ->storeManager = $ storeManager ;
58
+ $ this ->productFactory = $ productFactory ;
51
59
}
52
60
53
61
/**
@@ -64,7 +72,7 @@ public function prepareDataSource(array $dataSource)
64
72
if (isset ($ item [$ fieldName ])) {
65
73
$ item [$ fieldName . '_src ' ] = $ this ->getUrl ($ item [$ fieldName ]);
66
74
} else {
67
- $ category = new DataObject ($ item );
75
+ $ category = $ this -> productFactory -> create ($ item );
68
76
$ imageHelper = $ this ->imageHelper ->init ($ category , 'product_listing_thumbnail ' );
69
77
$ item [$ fieldName . '_src ' ] = $ imageHelper ->getUrl ();
70
78
}
0 commit comments