9
9
use Magento \CatalogInventory \Api \StockStateInterface ;
10
10
use Magento \CatalogInventory \Model \Spi \StockRegistryProviderInterface ;
11
11
use Magento \CatalogInventory \Model \Spi \StockStateProviderInterface ;
12
+ use Magento \Framework \DataObject ;
12
13
13
14
/**
14
15
* Interface StockState
@@ -50,12 +51,11 @@ public function __construct(
50
51
* @param int $scopeId
51
52
* @return bool
52
53
*/
53
- public function verifyStock ($ productId , $ scopeId = null )
54
+ public function verifyStock ($ productId , $ scopeId = null ): bool
54
55
{
55
- // if ($scopeId === null) {
56
- $ scopeId = $ this ->stockConfiguration ->getDefaultScopeId ();
57
- // }
56
+ $ scopeId = $ this ->stockConfiguration ->getDefaultScopeId ();
58
57
$ stockItem = $ this ->stockRegistryProvider ->getStockItem ($ productId , $ scopeId );
58
+
59
59
return $ this ->stockStateProvider ->verifyStock ($ stockItem );
60
60
}
61
61
@@ -64,12 +64,11 @@ public function verifyStock($productId, $scopeId = null)
64
64
* @param int $scopeId
65
65
* @return bool
66
66
*/
67
- public function verifyNotification ($ productId , $ scopeId = null )
67
+ public function verifyNotification ($ productId , $ scopeId = null ): bool
68
68
{
69
- // if ($scopeId === null) {
70
- $ scopeId = $ this ->stockConfiguration ->getDefaultScopeId ();
71
- // }
69
+ $ scopeId = $ this ->stockConfiguration ->getDefaultScopeId ();
72
70
$ stockItem = $ this ->stockRegistryProvider ->getStockItem ($ productId , $ scopeId );
71
+
73
72
return $ this ->stockStateProvider ->verifyNotification ($ stockItem );
74
73
}
75
74
@@ -79,15 +78,13 @@ public function verifyNotification($productId, $scopeId = null)
79
78
* @param int $productId
80
79
* @param float $qty
81
80
* @param int $scopeId
82
- * @exception \Magento\Framework\Exception\LocalizedException
83
81
* @return bool
84
82
*/
85
- public function checkQty ($ productId , $ qty , $ scopeId = null )
83
+ public function checkQty ($ productId , $ qty , $ scopeId = null ): bool
86
84
{
87
- // if ($scopeId === null) {
88
- $ scopeId = $ this ->stockConfiguration ->getDefaultScopeId ();
89
- // }
85
+ $ scopeId = $ this ->stockConfiguration ->getDefaultScopeId ();
90
86
$ stockItem = $ this ->stockRegistryProvider ->getStockItem ($ productId , $ scopeId );
87
+
91
88
return $ this ->stockStateProvider ->checkQty ($ stockItem , $ qty );
92
89
}
93
90
@@ -100,12 +97,11 @@ public function checkQty($productId, $qty, $scopeId = null)
100
97
* @param int $scopeId
101
98
* @return float
102
99
*/
103
- public function suggestQty ($ productId , $ qty , $ scopeId = null )
100
+ public function suggestQty ($ productId , $ qty , $ scopeId = null ): float
104
101
{
105
- // if ($scopeId === null) {
106
- $ scopeId = $ this ->stockConfiguration ->getDefaultScopeId ();
107
- // }
102
+ $ scopeId = $ this ->stockConfiguration ->getDefaultScopeId ();
108
103
$ stockItem = $ this ->stockRegistryProvider ->getStockItem ($ productId , $ scopeId );
104
+
109
105
return $ this ->stockStateProvider ->suggestQty ($ stockItem , $ qty );
110
106
}
111
107
@@ -116,27 +112,25 @@ public function suggestQty($productId, $qty, $scopeId = null)
116
112
* @param int $scopeId
117
113
* @return float
118
114
*/
119
- public function getStockQty ($ productId , $ scopeId = null )
115
+ public function getStockQty ($ productId , $ scopeId = null ): float
120
116
{
121
- // if ($scopeId === null) {
122
- $ scopeId = $ this ->stockConfiguration ->getDefaultScopeId ();
123
- // }
117
+ $ scopeId = $ this ->stockConfiguration ->getDefaultScopeId ();
124
118
$ stockItem = $ this ->stockRegistryProvider ->getStockItem ($ productId , $ scopeId );
119
+
125
120
return $ this ->stockStateProvider ->getStockQty ($ stockItem );
126
121
}
127
122
128
123
/**
129
124
* @param int $productId
130
125
* @param float $qty
131
126
* @param int $websiteId
132
- * @return \Magento\Framework\ DataObject
127
+ * @return DataObject
133
128
*/
134
- public function checkQtyIncrements ($ productId , $ qty , $ websiteId = null )
129
+ public function checkQtyIncrements ($ productId , $ qty , $ websiteId = null ): DataObject
135
130
{
136
- // if ($websiteId === null) {
137
- $ websiteId = $ this ->stockConfiguration ->getDefaultScopeId ();
138
- // }
131
+ $ websiteId = $ this ->stockConfiguration ->getDefaultScopeId ();
139
132
$ stockItem = $ this ->stockRegistryProvider ->getStockItem ($ productId , $ websiteId );
133
+
140
134
return $ this ->stockStateProvider ->checkQtyIncrements ($ stockItem , $ qty );
141
135
}
142
136
@@ -148,12 +142,11 @@ public function checkQtyIncrements($productId, $qty, $websiteId = null)
148
142
* @param int $scopeId
149
143
* @return int
150
144
*/
151
- public function checkQuoteItemQty ($ productId , $ itemQty , $ qtyToCheck , $ origQty , $ scopeId = null )
145
+ public function checkQuoteItemQty ($ productId , $ itemQty , $ qtyToCheck , $ origQty , $ scopeId = null ): int
152
146
{
153
- // if ($scopeId === null) {
154
- $ scopeId = $ this ->stockConfiguration ->getDefaultScopeId ();
155
- // }
147
+ $ scopeId = $ this ->stockConfiguration ->getDefaultScopeId ();
156
148
$ stockItem = $ this ->stockRegistryProvider ->getStockItem ($ productId , $ scopeId );
149
+
157
150
return $ this ->stockStateProvider ->checkQuoteItemQty ($ stockItem , $ itemQty , $ qtyToCheck , $ origQty );
158
151
}
159
152
}
0 commit comments