File tree Expand file tree Collapse file tree 2 files changed +35
-2
lines changed
app/code/Magento/CatalogImportExport/Model Expand file tree Collapse file tree 2 files changed +35
-2
lines changed Original file line number Diff line number Diff line change @@ -254,6 +254,16 @@ class Product extends \Magento\ImportExport\Model\Export\Entity\AbstractEntity
254
254
'tax_class_id ' => 'tax_class_name ' ,
255
255
];
256
256
257
+ /**
258
+ * Attributes codes which shows as date
259
+ *
260
+ * @var array
261
+ */
262
+ protected $ dateAttrCodes = [
263
+ 'special_from_date ' ,
264
+ 'special_to_date '
265
+ ];
266
+
257
267
/**
258
268
* Attributes codes which are appropriate for export and not the part of additional_attributes.
259
269
*
@@ -897,7 +907,15 @@ protected function collectRawData()
897
907
}
898
908
$ fieldName = isset ($ this ->_fieldsMap [$ code ]) ? $ this ->_fieldsMap [$ code ] : $ code ;
899
909
900
- if ($ this ->_attributeTypes [$ code ] === 'datetime ' ) {
910
+ if (in_array ($ code , $ this ->dateAttrCodes )) {
911
+ $ attrValue = $ this ->_localeDate ->formatDateTime (
912
+ new \DateTime ($ attrValue ),
913
+ \IntlDateFormatter::SHORT ,
914
+ \IntlDateFormatter::NONE ,
915
+ null ,
916
+ date_default_timezone_get ()
917
+ );
918
+ } else if ($ this ->_attributeTypes [$ code ] === 'datetime ' ) {
901
919
$ attrValue = $ this ->_localeDate ->formatDateTime (
902
920
new \DateTime ($ attrValue ),
903
921
\IntlDateFormatter::SHORT ,
Original file line number Diff line number Diff line change @@ -209,6 +209,16 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity
209
209
'_upsell_ ' => \Magento \Catalog \Model \Product \Link::LINK_TYPE_UPSELL ,
210
210
];
211
211
212
+ /**
213
+ * Attributes codes which shows as date
214
+ *
215
+ * @var array
216
+ */
217
+ protected $ dateAttrCodes = [
218
+ 'special_from_date ' ,
219
+ 'special_to_date '
220
+ ];
221
+
212
222
/**
213
223
* Need to log in import history
214
224
*
@@ -1642,7 +1652,12 @@ protected function _saveProducts()
1642
1652
$ attrTable = $ attribute ->getBackend ()->getTable ();
1643
1653
$ storeIds = [0 ];
1644
1654
1645
- if ('datetime ' == $ attribute ->getBackendType () && strtotime ($ attrValue )) {
1655
+ if (
1656
+ 'datetime ' == $ attribute ->getBackendType ()
1657
+ && in_array ($ attribute ->getAttributeCode (), $ this ->dateAttrCodes )
1658
+ ) {
1659
+ $ attrValue = $ this ->dateTime ->formatDate ($ attrValue , false );
1660
+ } else if ('datetime ' == $ attribute ->getBackendType () && strtotime ($ attrValue )) {
1646
1661
$ attrValue = $ this ->dateTime ->gmDate (
1647
1662
'Y-m-d H:i:s ' ,
1648
1663
$ this ->_localeDate ->date ($ attrValue )->getTimestamp ()
You can’t perform that action at this time.
0 commit comments