41
41
use Magento \Framework \Filesystem ;
42
42
use Magento \UrlRewrite \Model \UrlPersistInterface ;
43
43
use Magento \Catalog \Api \CategoryRepositoryInterface ;
44
+ use Magento \Eav \Model \Entity \Attribute \Source \Boolean ;
44
45
45
46
/**
46
47
* Entity Adapter for importing Magento Categories
@@ -274,6 +275,8 @@ public function __construct(
274
275
$ this ->getErrorAggregator ()->addErrorMessageTemplate ($ errorCode , $ message );
275
276
}
276
277
278
+ $ this ->config = $ config ;
279
+
277
280
$ this ->initOnTapAttributes ()
278
281
->initWebsites ()
279
282
->initStores ()
@@ -283,7 +286,6 @@ public function __construct(
283
286
284
287
$ this ->entityTable = $ this ->defaultCategory ->getResource ()->getEntityTable ();
285
288
$ this ->categoryImportVersionFeature = $ this ->versionFeatures ->create ('CategoryImportVersion ' );
286
- $ this ->config = $ config ;
287
289
}
288
290
289
291
/**
@@ -335,7 +337,13 @@ public function getAttributeOptions(AbstractAttribute $attribute): array
335
337
336
338
if ($ attribute ->usesSource ()) {
337
339
// should attribute has index (option value) instead of a label?
338
- $ index = in_array ($ attribute ->getAttributeCode (), $ this ->indexValueAttributes ) ? 'value ' : 'label ' ;
340
+ $ index = 'label ' ;
341
+ if (
342
+ in_array ($ attribute ->getAttributeCode (), $ this ->indexValueAttributes ) ||
343
+ $ attribute ->getSourceModel () == Boolean::class
344
+ ) {
345
+ $ index = 'value ' ;
346
+ };
339
347
340
348
// only default (admin) store values used
341
349
/** @var Attribute $attribute */
@@ -954,13 +962,13 @@ private function saveCategories(): self
954
962
955
963
$ time = !empty ($ rowData [CategoryModel::KEY_CREATED_AT ])
956
964
? strtotime ($ rowData [CategoryModel::KEY_CREATED_AT ])
957
- : null ;
965
+ : ' now ' ;
958
966
959
967
// entity table data
960
968
$ entityRow = [
961
969
CategoryInterface::KEY_PARENT_ID => $ parentCategory ['entity_id ' ],
962
970
CategoryInterface::KEY_LEVEL => $ parentCategory [CategoryInterface::KEY_LEVEL ] + 1 ,
963
- CategoryInterface::KEY_CREATED_AT => (new DateTime ($ time ))
971
+ CategoryInterface::KEY_CREATED_AT => (new \ DateTime ($ time ))
964
972
->format (DateTime::DATETIME_PHP_FORMAT ),
965
973
CategoryInterface::KEY_UPDATED_AT => "now() " ,
966
974
CategoryInterface::KEY_POSITION => $ rowData [CategoryInterface::KEY_POSITION ]
0 commit comments