Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
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->setTypeId(
40  \Magento\Catalog\Model\Product\Type::TYPE_SIMPLE
41 )->setId(
42  1
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  ['use_config_manage_stock' => 0]
59 )->setCategoryIds(
60  [9]
61 )->setVisibility(
62  \Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH
63 )->setStatus(
64  \Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED
65 )->save();
66 
67 $product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Catalog\Model\Product::class);
68 $product->setTypeId(
69  \Magento\Catalog\Model\Product\Type::TYPE_SIMPLE
70 )->setId(
71  2
72 )->setAttributeSetId(
73  $installer->getAttributeSetId('catalog_product', 'Default')
74 )->setStoreId(
75  1
76 )->setWebsiteIds(
77  [1]
78 )->setName(
79  'Simple Product Two'
80 )->setSku(
81  '12345'
82 )->setPrice(
83  45.67
84 )->setWeight(
85  56
86 )->setStockData(
87  ['use_config_manage_stock' => 0]
88 )->setCategoryIds(
89  [9]
90 )->setVisibility(
91  \Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH
92 )->setStatus(
93  \Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED
94 )->save();
$category
Definition: row_fixture.php:15
$installer
Definition: row_fixture.php:8
$product
Definition: row_fixture.php:38