Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
magento2-base
dev
tests
integration
testsuite
Magento
Catalog
_files
category_tree.php
Go to the documentation of this file.
1
<?php
11
$categories
= [
12
[
13
'id'
=> 400,
14
'name'
=>
'Category 1'
,
15
'parent_id'
=> 2,
16
'path'
=>
'1/2/400'
,
17
'level'
=> 2,
18
'available_sort_by'
=>
'name'
,
19
'default_sort_by'
=>
'name'
,
20
'is_active'
=>
true
,
21
'position'
=> 1,
22
],
23
[
24
'id'
=> 401,
25
'name'
=>
'Category 1.1'
,
26
'parent_id'
=> 400,
27
'path'
=>
'1/2/400/401'
,
28
'level'
=> 3,
29
'available_sort_by'
=>
'name'
,
30
'default_sort_by'
=>
'name'
,
31
'is_active'
=>
true
,
32
'position'
=> 1
33
],
34
[
35
'id'
=> 402,
36
'name'
=>
'Category 1.1.1'
,
37
'parent_id'
=> 401,
38
'path'
=>
'1/2/400/401/402'
,
39
'level'
=> 4,
40
'available_sort_by'
=>
'name'
,
41
'default_sort_by'
=>
'name'
,
42
'is_active'
=>
true
,
43
'position'
=> 1
44
],
45
];
46
foreach
(
$categories
as
$data
) {
47
$model
=
\Magento\TestFramework\Helper\Bootstrap::getObjectManager
()->create(
48
\
Magento
\Catalog\Model\Category::class
49
);
50
$model
->isObjectNew(
true
);
51
$model
->setId(
$data
[
'id'
])
52
->setName(
$data
[
'name'
])
53
->setParentId(
$data
[
'parent_id'
])
54
->setPath(
$data
[
'path'
])
55
->setLevel(
$data
[
'level'
])
56
->setAvailableSortBy(
$data
[
'available_sort_by'
])
57
->setDefaultSortBy(
$data
[
'default_sort_by'
])
58
->setIsActive(
$data
[
'is_active'
])
59
->setPosition(
$data
[
'position'
])
60
->setStoreId(0)
61
->save();
62
}
$model
$model
Definition:
enable_catalog_product_reindex_schedule.php:9
$data
$data
Definition:
attribute_set_with_image_attribute.php:16
Magento
$categories
$categories
Definition:
category_tree.php:11
Magento\TestFramework\Helper\Bootstrap\getObjectManager
static getObjectManager()
Definition:
Bootstrap.php:125