73 private static $backendTypeToFilterMapper = [
90 \Psr\Log\LoggerInterface
$logger,
97 $this->_exportConfig = $exportConfig;
98 $this->_entityFactory = $entityFactory;
99 $this->_exportAdapterFac = $exportAdapterFac;
112 if (!$this->_entityAdapter) {
113 $entities = $this->_exportConfig->getEntities();
115 if (isset($entities[$this->
getEntity()])) {
117 $this->_entityAdapter = $this->_entityFactory->create($entities[$this->
getEntity()][
'model']);
118 }
catch (\Exception $e) {
119 $this->_logger->critical($e);
120 throw new \Magento\Framework\Exception\LocalizedException(
121 __(
'Please enter a correct entity model.')
127 throw new \Magento\Framework\Exception\LocalizedException(
129 'The entity adapter object must be an instance of %1 or %2.',
137 if ($this->
getEntity() != $this->_entityAdapter->getEntityTypeCode()) {
138 throw new \Magento\Framework\Exception\LocalizedException(
139 __(
'The input entity code is not equal to entity adapter code.')
143 throw new \Magento\Framework\Exception\LocalizedException(
__(
'Please enter a correct entity.'));
145 $this->_entityAdapter->setParameters($this->
getData());
158 if (!$this->_writer) {
159 $fileFormats = $this->_exportConfig->getFileFormats();
163 $this->_writer = $this->_exportAdapterFac->create($fileFormats[$this->
getFileFormat()][
'model']);
164 }
catch (\Exception $e) {
165 $this->_logger->critical($e);
166 throw new \Magento\Framework\Exception\LocalizedException(
167 __(
'Please enter a correct entity model.')
171 throw new \Magento\Framework\Exception\LocalizedException(
173 'The adapter object must be an instance of %1.',
179 throw new \Magento\Framework\Exception\LocalizedException(
__(
'Please correct the file format.'));
193 if (isset($this->_data[self::FILTER_ELEMENT_GROUP])) {
196 $countRows = substr_count(trim(
$result),
"\n");
198 throw new \Magento\Framework\Exception\LocalizedException(
__(
'There is no data for the export.'));
201 $this->
addLogComment([
__(
'Exported %1 rows.', $countRows),
__(
'The export is finished.')]);
205 throw new \Magento\Framework\Exception\LocalizedException(
__(
'Please provide filter data.'));
231 return 'multiselect' ==
$attribute->getFrontendInput() ?
235 if (isset(self::$backendTypeToFilterMapper[
$attribute->getBackendType()])) {
236 return self::$backendTypeToFilterMapper[
$attribute->getBackendType()];
243 throw new \Magento\Framework\Exception\LocalizedException(
244 __(
'We can\'t determine the attribute filter type.')
257 if (in_array(
$attribute->getAttributeCode(), [
'category_ids',
'media_gallery'])) {
265 case \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER:
266 case \Magento\Framework\DB\Ddl\Table::TYPE_BIGINT:
269 case \Magento\Framework\DB\Ddl\Table::TYPE_DATE:
270 case \Magento\Framework\DB\Ddl\Table::TYPE_DATETIME:
271 case \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP:
298 if (empty($this->_data[
'entity'])) {
299 throw new \Magento\Framework\Exception\LocalizedException(
__(
'Entity is unknown'));
301 return $this->_data[
'entity'];
322 if (empty($this->_data[
'file_format'])) {
323 throw new \Magento\Framework\Exception\LocalizedException(
__(
'We can\'t identify this file format.'));
325 return $this->_data[
'file_format'];
338 $fileName = $entityAdapter->getFileName();
const FILTER_TYPE_MULTISELECT
getData($key='', $index=null)
const FILTER_ELEMENT_SKIP
static getAttributeFilterType(\Magento\Eav\Model\Entity\Attribute $attribute)
getEntityAttributeCollection()
static getStaticAttributeFilterType(\Magento\Eav\Model\Entity\Attribute $attribute)
__construct(\Psr\Log\LoggerInterface $logger, \Magento\Framework\Filesystem $filesystem, \Magento\ImportExport\Model\Export\ConfigInterface $exportConfig, \Magento\ImportExport\Model\Export\Entity\Factory $entityFactory, \Magento\ImportExport\Model\Export\Adapter\Factory $exportAdapterFac, array $data=[])
filterAttributeCollection(\Magento\Framework\Data\Collection $collection)
const FILTER_ELEMENT_GROUP
addLogComment($debugData)