/** * @param array $configData * @param string $entity * @param string[] $expectedResult * @dataProvider getEntityTypesDataProvider */ public function testGetEntityTypes($configData, $entity, $expectedResult) { $this->_configScopeMock->expects($this->any())->method('load')->with($this->_cacheId)->will($this->returnValue(false)); $this->_readerMock->expects($this->any())->method('read')->will($this->returnValue($configData)); $this->_model = new \Magento\ImportExport\Model\Import\Config($this->_readerMock, $this->_configScopeMock, $this->_cacheId); $this->assertEquals($expectedResult, $this->_model->getEntityTypes($entity)); }
/** * 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; }