/** * {@inheritdoc} */ public function toOptionArray() { $options = []; foreach ($this->_exportConfig->getFileFormats() as $formatName => $formatConfig) { $options[] = ['value' => $formatName, 'label' => __($formatConfig['label'])]; } return $options; }
/** * {@inheritdoc} */ public function toOptionArray() { $options = []; $options[] = ['label' => __('-- Please Select --'), 'value' => '']; foreach ($this->_exportConfig->getEntities() as $entityName => $entityConfig) { $options[] = ['value' => $entityName, 'label' => __($entityConfig['label'])]; } return $options; }
/** * Get writer object. * * @return \Magento\ImportExport\Model\Export\Adapter\AbstractAdapter * @throws \Magento\Framework\Exception\LocalizedException */ protected function _getWriter() { if (!$this->_writer) { $fileFormats = $this->_exportConfig->getFileFormats(); if (isset($fileFormats[$this->getFileFormat()])) { try { $this->_writer = $this->_exportAdapterFac->create($fileFormats[$this->getFileFormat()]['model']); } catch (\Exception $e) { $this->_logger->critical($e); throw new \Magento\Framework\Exception\LocalizedException(__('Please enter a correct entity model.')); } if (!$this->_writer instanceof \Magento\ImportExport\Model\Export\Adapter\AbstractAdapter) { throw new \Magento\Framework\Exception\LocalizedException(__('The adapter object must be an instance of %1.', 'Magento\\ImportExport\\Model\\Export\\Adapter\\AbstractAdapter')); } } else { throw new \Magento\Framework\Exception\LocalizedException(__('Please correct the file format.')); } } return $this->_writer; }
/** * Initialize product type models. * * @throws \Magento\Framework\Exception\LocalizedException * @return $this */ protected function initTypeModels() { $productTypes = $this->_exportConfig->getEntityTypes($this->getEntityTypeCode()); foreach ($productTypes as $productTypeName => $productTypeConfig) { if (!($model = $this->_typeFactory->create($productTypeConfig['model']))) { throw new \Magento\Framework\Exception\LocalizedException(__('Entity type model \'%1\' is not found', $productTypeConfig['model'])); } if (!$model instanceof \Magento\CatalogImportExport\Model\Export\Product\Type\AbstractType) { throw new \Magento\Framework\Exception\LocalizedException(__('Entity type model must be an instance of' . ' \\Magento\\CatalogImportExport\\Model\\Export\\Product\\Type\\AbstractType')); } if ($model->isSuitable()) { $this->_productTypeModels[$productTypeName] = $model; $this->_disabledAttrs = array_merge($this->_disabledAttrs, $model->getDisabledAttrs()); $this->_indexValueAttributes = array_merge($this->_indexValueAttributes, $model->getIndexValueAttributes()); } } if (!$this->_productTypeModels) { throw new \Magento\Framework\Exception\LocalizedException(__('There are no product types available for export.')); } $this->_disabledAttrs = array_unique($this->_disabledAttrs); return $this; }