Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
catalog_category_with_apostrophe.php
Go to the documentation of this file.
1 <?php
9 
10 $categoryFirst = $objectManager->create(\Magento\Catalog\Model\Category::class);
11 $categoryFirst->setName('Category 1')
12  ->setPath('1/2')
13  ->setLevel(2)
14  ->setAvailableSortBy('name')
15  ->setDefaultSortBy('name')
16  ->setIsActive(true)
17  ->setPosition(1)
18  ->save();
19 
20 // products from this fixture were moved to indexer_catalog_products.php
21 $categorySecond = $objectManager->create(\Magento\Catalog\Model\Category::class);
22 $categorySecond->setName('\'Category 6\'')
23  ->setPath($categoryFirst->getPath())
24  ->setLevel(3)
25  ->setAvailableSortBy('name')
26  ->setDefaultSortBy('name')
27  ->setIsActive(true)
28  ->setPosition(1)
29  ->save();