Skip to content

Commit 11d0a35

Browse files
committed
magento/adobe-stock-integration#1711: Use product model instead of data object for catalog image helper init
1 parent d598c12 commit 11d0a35

File tree

1 file changed

+10
-2
lines changed
  • app/code/Magento/MediaGalleryCatalogUi/Ui/Component/Listing/Columns

1 file changed

+10
-2
lines changed

app/code/Magento/MediaGalleryCatalogUi/Ui/Component/Listing/Columns/Thumbnail.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
namespace Magento\MediaGalleryCatalogUi\Ui\Component\Listing\Columns;
77

88
use Magento\Catalog\Helper\Image;
9-
use Magento\Framework\DataObject;
9+
use Magento\Catalog\Model\ProductFactory;
1010
use Magento\Framework\View\Element\UiComponent\ContextInterface;
1111
use Magento\Framework\View\Element\UiComponentFactory;
1212
use 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

Comments
 (0)