/** * Initialize product type models. * * @return $this * @throws \Magento\Framework\Exception\LocalizedException */ protected function _initTypeModels() { $productTypes = $this->_importConfig->getEntityTypes($this->getEntityTypeCode()); foreach ($productTypes as $productTypeName => $productTypeConfig) { $params = [$this, $productTypeName]; if (!($model = $this->_productTypeFactory->create($productTypeConfig['model'], ['params' => $params]))) { throw new \Magento\Framework\Exception\LocalizedException(__('Entity type model \'%1\' is not found', $productTypeConfig['model'])); } if (!$model instanceof \Magento\CatalogImportExport\Model\Import\Product\Type\AbstractType) { throw new \Magento\Framework\Exception\LocalizedException(__('Entity type model must be an instance of ' . 'Magento\\CatalogImportExport\\Model\\Import\\Product\\Type\\AbstractType')); } if ($model->isSuitable()) { $this->_productTypeModels[$productTypeName] = $model; } $this->_fieldsMap = array_merge($this->_fieldsMap, $model->getCustomFieldsMapping()); $this->_specialAttributes = array_merge($this->_specialAttributes, $model->getParticularAttributes()); } $this->_initErrorTemplates(); // remove doubles $this->_specialAttributes = array_unique($this->_specialAttributes); return $this; }
/** * Initialize product type models. * * @return $this * @throws \Magento\Framework\Model\Exception */ protected function _initTypeModels() { $productTypes = $this->_importConfig->getEntityTypes($this->getEntityTypeCode()); foreach ($productTypes as $productTypeName => $productTypeConfig) { $params = array($this, $productTypeName); if (!($model = $this->_productTypeFactory->create($productTypeConfig['model'], array('params' => $params)))) { throw new \Magento\Framework\Model\Exception(sprintf("Entity type model '%s' is not found", $productTypeConfig['model'])); } if (!$model instanceof \Magento\CatalogImportExport\Model\Import\Product\Type\AbstractType) { throw new \Magento\Framework\Model\Exception(__('Entity type model must be an instance of ' . 'Magento\\CatalogImportExport\\Model\\Import\\Product\\Type\\AbstractType')); } if ($model->isSuitable()) { $this->_productTypeModels[$productTypeName] = $model; } $this->_specialAttributes = array_merge($this->_specialAttributes, $model->getParticularAttributes()); } // remove doubles $this->_specialAttributes = array_unique($this->_specialAttributes); return $this; }