Skip to content

Commit 8d3a237

Browse files
#42 - Dynamically fill the image keys
1 parent fc97826 commit 8d3a237

File tree

1 file changed

+24
-2
lines changed
  • app/code/Magento/CatalogImportExport/Model/Import

1 file changed

+24
-2
lines changed

app/code/Magento/CatalogImportExport/Model/Import/Product.php

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity
425425
*
426426
* @var string[]
427427
*/
428-
protected $_imagesArrayKeys = ['image', 'small_image', 'thumbnail', 'swatch_image', '_media_image'];
428+
protected $_imagesArrayKeys = [];
429429

430430
/**
431431
* Permanent entity columns.
@@ -833,7 +833,8 @@ public function __construct(
833833

834834
$this->_initAttributeSets()
835835
->_initTypeModels()
836-
->_initSkus();
836+
->_initSkus()
837+
->_initImagesArrayKeys();
837838
$this->validator->init($this);
838839
}
839840

@@ -1076,6 +1077,27 @@ protected function _initSkus()
10761077
return $this;
10771078
}
10781079

1080+
/**
1081+
* Initialize image array keys.
1082+
*
1083+
* @return $this
1084+
*/
1085+
protected function _initImagesArrayKeys()
1086+
{
1087+
$select = $this->_connection->select()->from(
1088+
$this->getResource()->getTable('eav_attribute'),
1089+
['code' => 'attribute_code']
1090+
)->where(
1091+
'frontend_input = :frontend_input'
1092+
);
1093+
$bind = [':frontend_input' => 'media_image'];
1094+
1095+
$this->_imagesArrayKeys = $this->_connection->fetchCol($select, $bind);
1096+
$this->_imagesArrayKeys[] = '_media_image';
1097+
1098+
return $this;
1099+
}
1100+
10791101
/**
10801102
* Initialize product type models.
10811103
*

0 commit comments

Comments
 (0)