|
12 | 12 | use Magento\Catalog\Model\Product\Attribute\Source\Status; |
13 | 13 | use Magento\Catalog\Model\Product\Visibility; |
14 | 14 |
|
| 15 | +$categoryId = 333; |
| 16 | +$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); |
| 17 | +$attributeSet = $objectManager->create(\Magento\Eav\Model\Entity\Attribute\Set::class); |
| 18 | +$entityType = $objectManager->create(\Magento\Eav\Model\Entity\Type::class)->loadByCode('catalog_product'); |
| 19 | +$defaultSetId = $objectManager->create(\Magento\Catalog\Model\Product::class)->getDefaultAttributeSetid(); |
| 20 | + |
15 | 21 | $products = [ |
16 | 22 | [ |
17 | 23 | 'type' => 'simple', |
18 | | - 'id' => 201, |
19 | 24 | 'name' => 'search product 1', |
20 | 25 | 'sku' => '24 MB06', |
21 | 26 | 'status' => Status::STATUS_ENABLED, |
22 | 27 | 'visibility' => Visibility::VISIBILITY_BOTH, |
23 | | - 'attribute_set' => 4, |
24 | | - 'website_ids' => [1], |
| 28 | + 'attribute_set' => $defaultSetId, |
| 29 | + 'website_ids' => [\Magento\Store\Model\Store::DISTRO_STORE_ID], |
25 | 30 | 'price' => 10, |
26 | | - 'category_id' => 333, |
| 31 | + 'category_id' => $categoryId, |
27 | 32 | 'meta_title' => 'Key Title', |
28 | 33 | 'meta_keyword' => 'meta keyword', |
29 | 34 | 'meta_description' => 'meta description', |
30 | 35 | ], |
31 | 36 | [ |
32 | 37 | 'type' => 'simple', |
33 | | - 'id' => 202, |
34 | 38 | 'name' => 'search product 2', |
35 | 39 | 'sku' => '24 MB04', |
36 | 40 | 'status' => Status::STATUS_ENABLED, |
37 | 41 | 'visibility' => Visibility::VISIBILITY_BOTH, |
38 | | - 'attribute_set' => 4, |
39 | | - 'website_ids' => [1], |
| 42 | + 'attribute_set' => $defaultSetId, |
| 43 | + 'website_ids' => [\Magento\Store\Model\Store::DISTRO_STORE_ID], |
40 | 44 | 'price' => 10, |
41 | | - 'category_id' => 333, |
| 45 | + 'category_id' => $categoryId, |
42 | 46 | 'meta_title' => 'Last Title', |
43 | 47 | 'meta_keyword' => 'meta keyword', |
44 | 48 | 'meta_description' => 'meta description', |
45 | 49 | ], |
46 | 50 | [ |
47 | 51 | 'type' => 'simple', |
48 | | - 'id' => 203, |
49 | 52 | 'name' => 'search product 3', |
50 | 53 | 'sku' => '24 MB02', |
51 | 54 | 'status' => Status::STATUS_ENABLED, |
52 | 55 | 'visibility' => Visibility::VISIBILITY_BOTH, |
53 | | - 'attribute_set' => 4, |
54 | | - 'website_ids' => [1], |
| 56 | + 'attribute_set' => $defaultSetId, |
| 57 | + 'website_ids' => [\Magento\Store\Model\Store::DISTRO_STORE_ID], |
55 | 58 | 'price' => 20, |
56 | | - 'category_id' => 333, |
| 59 | + 'category_id' => $categoryId, |
57 | 60 | 'meta_title' => 'First Title', |
58 | 61 | 'meta_keyword' => 'meta keyword', |
59 | 62 | 'meta_description' => 'meta description', |
60 | 63 | ], |
61 | 64 | [ |
62 | 65 | 'type' => 'simple', |
63 | | - 'id' => 204, |
64 | 66 | 'name' => 'search product 4', |
65 | 67 | 'sku' => '24 MB01', |
66 | 68 | 'status' => Status::STATUS_ENABLED, |
67 | 69 | 'visibility' => Visibility::VISIBILITY_BOTH, |
68 | | - 'attribute_set' => 4, |
69 | | - 'website_ids' => [1], |
| 70 | + 'attribute_set' => $defaultSetId, |
| 71 | + 'website_ids' => [\Magento\Store\Model\Store::DISTRO_STORE_ID], |
70 | 72 | 'price' => 30, |
71 | | - 'category_id' => 333, |
| 73 | + 'category_id' => $categoryId, |
72 | 74 | 'meta_title' => 'A title', |
73 | 75 | 'meta_keyword' => 'meta keyword', |
74 | 76 | 'meta_description' => 'meta description', |
75 | 77 | ], |
76 | 78 | ]; |
77 | 79 |
|
78 | 80 | /** @var CategoryLinkManagementInterface $categoryLinkManagement */ |
79 | | -$categoryLinkManagement = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() |
80 | | - ->create(CategoryLinkManagementInterface::class); |
| 81 | +$categoryLinkManagement = $objectManager->create(CategoryLinkManagementInterface::class); |
81 | 82 |
|
82 | 83 | $categoriesToAssign = []; |
83 | 84 |
|
84 | 85 | foreach ($products as $data) { |
85 | 86 | /** @var $product Product */ |
86 | | - $product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(Product::class); |
| 87 | + $product = $objectManager->create(Product::class); |
87 | 88 | $product |
88 | 89 | ->setTypeId($data['type']) |
89 | | - ->setId($data['id']) |
90 | 90 | ->setAttributeSetId($data['attribute_set']) |
91 | 91 | ->setWebsiteIds($data['website_ids']) |
92 | 92 | ->setName($data['name']) |
|
0 commit comments