Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
price_row_fixture.php
Go to the documentation of this file.
1 <?php
9  \Magento\Catalog\Setup\CategorySetup::class
10 );
16 $category->isObjectNew(true);
17 $category->setId(
18  9
19 )->setName(
20  'Category 9'
21 )->setParentId(
22  2
23 )->setPath(
24  '1/2/3'
25 )->setLevel(
26  2
27 )->setAvailableSortBy(
28  'name'
29 )->setDefaultSortBy(
30  'name'
31 )->setIsActive(
32  true
33 )->setPosition(
34  1
35 )->save();
36 
39 $product->setId(
40  1
41 )->setTypeId(
42  \Magento\Catalog\Model\Product\Type::TYPE_SIMPLE
43 )->setAttributeSetId(
44  $installer->getAttributeSetId('catalog_product', 'Default')
45 )->setStoreId(
46  1
47 )->setWebsiteIds(
48  [1]
49 )->setName(
50  'Simple Product One'
51 )->setSku(
52  'simple'
53 )->setPrice(
54  10
55 )->setWeight(
56  18
57 )->setStockData(
58  [
59  'use_config_manage_stock' => 1,
60  'qty' => 100,
61  'is_qty_decimal' => 0,
62  'is_in_stock' => 1,
63  ]
64 )->setVisibility(
65  \Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH
66 )->setStatus(
67  \Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED
68 )->save();
71 $categoryLinkManagement = $objectManager->create(\Magento\Catalog\Api\CategoryLinkManagementInterface::class);
72 $categoryLinkManagement->assignProductToCategories('simple', [9]);
$objectManager
$installer
$categoryLinkManagement