66namespace Magento \MediaGalleryCatalogUi \Ui \Component \Listing \Columns ;
77
88use Magento \Catalog \Helper \Image ;
9- use Magento \Framework \ DataObject ;
9+ use Magento \Catalog \ Model \ ProductFactory ;
1010use Magento \Framework \View \Element \UiComponent \ContextInterface ;
1111use Magento \Framework \View \Element \UiComponentFactory ;
1212use Magento \Store \Model \Store ;
@@ -29,11 +29,17 @@ class Thumbnail extends Column
2929 */
3030 private $ imageHelper ;
3131
32+ /**
33+ * @var ProductFactory
34+ */
35+ private $ productFactory ;
36+
3237 /**
3338 * @param ContextInterface $context
3439 * @param UiComponentFactory $uiComponentFactory
3540 * @param StoreManagerInterface $storeManager
3641 * @param Image $image
42+ * @param ProductFactory $productFactory
3743 * @param array $components
3844 * @param array $data
3945 */
@@ -42,12 +48,14 @@ public function __construct(
4248 UiComponentFactory $ uiComponentFactory ,
4349 StoreManagerInterface $ storeManager ,
4450 Image $ image ,
51+ ProductFactory $ productFactory ,
4552 array $ components = [],
4653 array $ data = []
4754 ) {
4855 parent ::__construct ($ context , $ uiComponentFactory , $ components , $ data );
4956 $ this ->imageHelper = $ image ;
5057 $ this ->storeManager = $ storeManager ;
58+ $ this ->productFactory = $ productFactory ;
5159 }
5260
5361 /**
@@ -64,7 +72,7 @@ public function prepareDataSource(array $dataSource)
6472 if (isset ($ item [$ fieldName ])) {
6573 $ item [$ fieldName . '_src ' ] = $ this ->getUrl ($ item [$ fieldName ]);
6674 } else {
67- $ category = new DataObject ($ item );
75+ $ category = $ this -> productFactory -> create ($ item );
6876 $ imageHelper = $ this ->imageHelper ->init ($ category , 'product_listing_thumbnail ' );
6977 $ item [$ fieldName . '_src ' ] = $ imageHelper ->getUrl ();
7078 }
0 commit comments