/** * Create instance of entity adapter and return it * * @return \Magento\ImportExport\Model\Export\Entity\AbstractEntity|\Magento\ImportExport\Model\Export\AbstractEntity * @throws \Magento\Framework\Exception\LocalizedException */ protected function _getEntityAdapter() { if (!$this->_entityAdapter) { $entities = $this->_exportConfig->getEntities(); if (isset($entities[$this->getEntity()])) { try { $this->_entityAdapter = $this->_entityFactory->create($entities[$this->getEntity()]['model']); } catch (\Exception $e) { $this->_logger->critical($e); throw new \Magento\Framework\Exception\LocalizedException(__('Please enter a correct entity model.')); } if (!$this->_entityAdapter instanceof \Magento\ImportExport\Model\Export\Entity\AbstractEntity && !$this->_entityAdapter instanceof \Magento\ImportExport\Model\Export\AbstractEntity) { throw new \Magento\Framework\Exception\LocalizedException(__('The entity adapter object must be an instance of %1 or %2.', 'Magento\\ImportExport\\Model\\Export\\Entity\\AbstractEntity', 'Magento\\ImportExport\\Model\\Export\\AbstractEntity')); } // check for entity codes integrity if ($this->getEntity() != $this->_entityAdapter->getEntityTypeCode()) { throw new \Magento\Framework\Exception\LocalizedException(__('The input entity code is not equal to entity adapter code.')); } } else { throw new \Magento\Framework\Exception\LocalizedException(__('Please enter a correct entity.')); } $this->_entityAdapter->setParameters($this->getData()); } return $this->_entityAdapter; }