7
7
8
8
namespace Magento \Catalog \Api ;
9
9
10
+ use Magento \Catalog \Api \Data \ProductAttributeInterface ;
11
+ use Magento \Catalog \Model \Product \Attribute \Source \Status ;
10
12
use Magento \Catalog \Model \Product \Type ;
13
+ use Magento \Catalog \Model \Product \Visibility ;
11
14
use Magento \Catalog \Model \ResourceModel \Product \Website \Link ;
15
+ use Magento \Eav \Model \Config ;
12
16
use Magento \Framework \ObjectManagerInterface ;
13
17
use Magento \Framework \Registry ;
14
18
use Magento \Framework \Webapi \Rest \Request ;
@@ -48,14 +52,18 @@ class ProductRepositoryAllStoreViewsTest extends WebapiAbstract
48
52
private $ storeManager ;
49
53
50
54
/**
51
- * @var string
55
+ * @var Link
52
56
*/
53
- private $ productSku = 'simple ' ;
57
+ private $ productWebsiteLink ;
58
+ /**
59
+ * @var Config
60
+ */
61
+ private $ eavConfig ;
54
62
55
63
/**
56
- * @var Link
64
+ * @var string
57
65
*/
58
- private $ productWebsiteLink ;
66
+ private $ productSku = ' simple ' ;
59
67
60
68
/**
61
69
* @inheritdoc
@@ -66,6 +74,7 @@ protected function setUp(): void
66
74
$ this ->objectManager = Bootstrap::getObjectManager ();
67
75
$ this ->productRepository = $ this ->objectManager ->get (ProductRepositoryInterface::class);
68
76
$ this ->productRepository ->cleanCache ();
77
+ $ this ->eavConfig = $ this ->objectManager ->get (Config::class);
69
78
$ this ->registry = $ this ->objectManager ->get (Registry::class);
70
79
$ this ->storeManager = $ this ->objectManager ->get (StoreManagerInterface::class);
71
80
$ this ->productWebsiteLink = $ this ->objectManager ->get (Link::class);
@@ -137,15 +146,18 @@ private function saveProduct($product): array
137
146
*/
138
147
private function getProductData (): array
139
148
{
149
+ $ setId =(int )$ this ->eavConfig ->getEntityType (ProductAttributeInterface::ENTITY_TYPE_CODE )
150
+ ->getDefaultAttributeSetId ();
151
+
140
152
return [
141
153
'sku ' => $ this ->productSku ,
142
154
'name ' => 'simple ' ,
143
155
'type_id ' => Type::TYPE_SIMPLE ,
144
156
'weight ' => 1 ,
145
- 'attribute_set_id ' => 4 ,
157
+ 'attribute_set_id ' => $ setId ,
146
158
'price ' => 10 ,
147
- 'status ' => 1 ,
148
- 'visibility ' => 4 ,
159
+ 'status ' => Status:: STATUS_ENABLED ,
160
+ 'visibility ' => Visibility:: VISIBILITY_BOTH ,
149
161
'extension_attributes ' => [
150
162
'stock_item ' => ['is_in_stock ' => true , 'qty ' => 1000 ]
151
163
],
0 commit comments