Skip to content

Commit

Permalink
magento/adobe-stock-integration#1711: Use product model instead of da…
Browse files Browse the repository at this point in the history
…ta object for catalog image helper init
  • Loading branch information
jmonteros422 committed Aug 7, 2020
1 parent d598c12 commit 11d0a35
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
namespace Magento\MediaGalleryCatalogUi\Ui\Component\Listing\Columns;

use Magento\Catalog\Helper\Image;
use Magento\Framework\DataObject;
use Magento\Catalog\Model\ProductFactory;
use Magento\Framework\View\Element\UiComponent\ContextInterface;
use Magento\Framework\View\Element\UiComponentFactory;
use Magento\Store\Model\Store;
Expand All @@ -29,11 +29,17 @@ class Thumbnail extends Column
*/
private $imageHelper;

/**
* @var ProductFactory
*/
private $productFactory;

/**
* @param ContextInterface $context
* @param UiComponentFactory $uiComponentFactory
* @param StoreManagerInterface $storeManager
* @param Image $image
* @param ProductFactory $productFactory
* @param array $components
* @param array $data
*/
Expand All @@ -42,12 +48,14 @@ public function __construct(
UiComponentFactory $uiComponentFactory,
StoreManagerInterface $storeManager,
Image $image,
ProductFactory $productFactory,
array $components = [],
array $data = []
) {
parent::__construct($context, $uiComponentFactory, $components, $data);
$this->imageHelper = $image;
$this->storeManager = $storeManager;
$this->productFactory = $productFactory;
}

/**
Expand All @@ -64,7 +72,7 @@ public function prepareDataSource(array $dataSource)
if (isset($item[$fieldName])) {
$item[$fieldName . '_src'] = $this->getUrl($item[$fieldName]);
} else {
$category = new DataObject($item);
$category = $this->productFactory->create($item);
$imageHelper = $this->imageHelper->init($category, 'product_listing_thumbnail');
$item[$fieldName . '_src'] = $imageHelper->getUrl();
}
Expand Down

0 comments on commit 11d0a35

Please sign in to comment.