Skip to content

Commit

Permalink
#42 - Dynamically fill the image keys
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentMarmiesse committed Jan 4, 2018
1 parent fc97826 commit 8d3a237
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions app/code/Magento/CatalogImportExport/Model/Import/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity
*
* @var string[]
*/
protected $_imagesArrayKeys = ['image', 'small_image', 'thumbnail', 'swatch_image', '_media_image'];
protected $_imagesArrayKeys = [];

/**
* Permanent entity columns.
Expand Down Expand Up @@ -833,7 +833,8 @@ public function __construct(

$this->_initAttributeSets()
->_initTypeModels()
->_initSkus();
->_initSkus()
->_initImagesArrayKeys();
$this->validator->init($this);
}

Expand Down Expand Up @@ -1076,6 +1077,27 @@ protected function _initSkus()
return $this;
}

/**
* Initialize image array keys.
*
* @return $this
*/
protected function _initImagesArrayKeys()
{
$select = $this->_connection->select()->from(
$this->getResource()->getTable('eav_attribute'),
['code' => 'attribute_code']
)->where(
'frontend_input = :frontend_input'
);
$bind = [':frontend_input' => 'media_image'];

$this->_imagesArrayKeys = $this->_connection->fetchCol($select, $bind);
$this->_imagesArrayKeys[] = '_media_image';

return $this;
}

/**
* Initialize product type models.
*
Expand Down

0 comments on commit 8d3a237

Please sign in to comment.