51
51
*/
52
52
class Import extends AbstractModel
53
53
{
54
- const BEHAVIOR_APPEND = 'append ' ;
55
- const BEHAVIOR_ADD_UPDATE = 'add_update ' ;
56
- const BEHAVIOR_REPLACE = 'replace ' ;
57
- const BEHAVIOR_DELETE = 'delete ' ;
58
- const BEHAVIOR_CUSTOM = 'custom ' ;
54
+ public const BEHAVIOR_APPEND = 'append ' ;
55
+ public const BEHAVIOR_ADD_UPDATE = 'add_update ' ;
56
+ public const BEHAVIOR_REPLACE = 'replace ' ;
57
+ public const BEHAVIOR_DELETE = 'delete ' ;
58
+ public const BEHAVIOR_CUSTOM = 'custom ' ;
59
59
60
60
/**
61
61
* Import source file.
62
62
*/
63
- const FIELD_NAME_SOURCE_FILE = 'import_file ' ;
63
+ public const FIELD_NAME_SOURCE_FILE = 'import_file ' ;
64
64
65
65
/**
66
66
* Import image archive.
67
67
*/
68
- const FIELD_NAME_IMG_ARCHIVE_FILE = 'import_image_archive ' ;
68
+ public const FIELD_NAME_IMG_ARCHIVE_FILE = 'import_image_archive ' ;
69
69
70
70
/**
71
71
* Import images file directory.
72
72
*/
73
- const FIELD_NAME_IMG_FILE_DIR = 'import_images_file_dir ' ;
73
+ public const FIELD_NAME_IMG_FILE_DIR = 'import_images_file_dir ' ;
74
74
75
75
/**
76
76
* Allowed errors count field name
77
77
*/
78
- const FIELD_NAME_ALLOWED_ERROR_COUNT = 'allowed_error_count ' ;
78
+ public const FIELD_NAME_ALLOWED_ERROR_COUNT = 'allowed_error_count ' ;
79
79
80
80
/**
81
81
* Validation startegt field name
82
82
*/
83
- const FIELD_NAME_VALIDATION_STRATEGY = 'validation_strategy ' ;
83
+ public const FIELD_NAME_VALIDATION_STRATEGY = 'validation_strategy ' ;
84
84
85
85
/**
86
86
* Import field separator.
87
87
*/
88
- const FIELD_FIELD_SEPARATOR = '_import_field_separator ' ;
88
+ public const FIELD_FIELD_SEPARATOR = '_import_field_separator ' ;
89
89
90
90
/**
91
91
* Import multiple value separator.
92
92
*/
93
- const FIELD_FIELD_MULTIPLE_VALUE_SEPARATOR = '_import_multiple_value_separator ' ;
93
+ public const FIELD_FIELD_MULTIPLE_VALUE_SEPARATOR = '_import_multiple_value_separator ' ;
94
94
95
95
/**
96
96
* Import empty attribute value constant.
97
97
*/
98
- const FIELD_EMPTY_ATTRIBUTE_VALUE_CONSTANT = '_import_empty_attribute_value_constant ' ;
98
+ public const FIELD_EMPTY_ATTRIBUTE_VALUE_CONSTANT = '_import_empty_attribute_value_constant ' ;
99
99
100
100
/**
101
101
* Allow multiple values wrapping in double quotes for additional attributes.
102
102
*/
103
- const FIELDS_ENCLOSURE = 'fields_enclosure ' ;
103
+ public const FIELDS_ENCLOSURE = 'fields_enclosure ' ;
104
104
105
105
/**
106
106
* default delimiter for several values in one cell as default for FIELD_FIELD_MULTIPLE_VALUE_SEPARATOR
107
107
*/
108
- const DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR = ', ' ;
108
+ public const DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR = ', ' ;
109
109
110
110
/**
111
111
* Import empty attribute default value
112
112
*/
113
- const DEFAULT_EMPTY_ATTRIBUTE_VALUE_CONSTANT = '__EMPTY__VALUE__ ' ;
114
- const DEFAULT_SIZE = 50 ;
115
- const MAX_IMPORT_CHUNKS = 4 ;
116
- const IMPORT_HISTORY_DIR = 'import_history/ ' ;
117
- const IMPORT_DIR = 'import/ ' ;
113
+ public const DEFAULT_EMPTY_ATTRIBUTE_VALUE_CONSTANT = '__EMPTY__VALUE__ ' ;
114
+ public const DEFAULT_SIZE = 50 ;
115
+ public const MAX_IMPORT_CHUNKS = 4 ;
116
+ public const IMPORT_HISTORY_DIR = 'import_history/ ' ;
117
+ public const IMPORT_DIR = 'import/ ' ;
118
118
119
119
/**
120
120
* @var AbstractEntity|ImportAbstractEntity
121
121
*/
122
122
protected $ _entityAdapter ;
123
123
124
124
/**
125
- * Import export data
126
- *
127
125
* @var DataHelper
128
126
*/
129
127
protected $ _importExportData = null ;
@@ -134,7 +132,6 @@ class Import extends AbstractModel
134
132
private $ _coreConfig ;
135
133
136
134
/**
137
- * @var \Magento\ImportExport\Model\Import\ConfigInterface
138
135
* @var ConfigInterface
139
136
*/
140
137
protected $ _importConfig ;
@@ -577,7 +574,7 @@ public function uploadSource()
577
574
throw new LocalizedException (__ ('The file cannot be uploaded. ' ));
578
575
}
579
576
580
- // phpcs:disable Magento2.Functions.DiscouragedFunction.Discouraged
577
+ // phpcs:ignore Magento2.Functions.DiscouragedFunction
581
578
$ extension = pathinfo ($ result ['file ' ], PATHINFO_EXTENSION );
582
579
583
580
$ uploadedFile = $ result ['path ' ] . $ result ['file ' ];
@@ -638,10 +635,11 @@ public function uploadFileAndGetSource()
638
635
*/
639
636
protected function _removeBom ($ sourceFile )
640
637
{
641
- $ string = $ this ->_varDirectory ->readFile ($ this ->_varDirectory ->getRelativePath ($ sourceFile ));
638
+ $ driver = $ this ->_varDirectory ->getDriver ();
639
+ $ string = $ driver ->fileGetContents ($ this ->_varDirectory ->getAbsolutePath ($ sourceFile ));
642
640
if ($ string !== false && substr ($ string , 0 , 3 ) == pack ("CCC " , 0xef , 0xbb , 0xbf )) {
643
641
$ string = substr ($ string , 3 );
644
- $ this -> _varDirectory -> writeFile ($ this ->_varDirectory ->getRelativePath ($ sourceFile ), $ string );
642
+ $ driver -> filePutContents ($ this ->_varDirectory ->getAbsolutePath ($ sourceFile ), $ string );
645
643
}
646
644
return $ this ;
647
645
}
0 commit comments