Skip to content

Commit 293da5a

Browse files
author
Stanislav Idolov
authored
ENGCOM-3164: Fix bool scope config and update throws and update use clases #18065
2 parents 584564f + 387b262 commit 293da5a

File tree

33 files changed

+333
-166
lines changed

33 files changed

+333
-166
lines changed

app/code/Magento/AdvancedSearch/Model/Recommendations/DataProvider.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
use Magento\Search\Model\QueryInterface;
1111
use Magento\AdvancedSearch\Model\SuggestedQueriesInterface;
1212

13+
/**
14+
* Class DataProvider
15+
*/
1316
class DataProvider implements SuggestedQueriesInterface
1417
{
1518
/**
@@ -51,6 +54,8 @@ class DataProvider implements SuggestedQueriesInterface
5154
private $recommendationsFactory;
5255

5356
/**
57+
* DataProvider constructor.
58+
*
5459
* @param ScopeConfigInterface $scopeConfig
5560
* @param \Magento\Catalog\Model\Layer\Resolver $layerResolver
5661
* @param \Magento\AdvancedSearch\Model\ResourceModel\RecommendationsFactory $recommendationsFactory
@@ -69,18 +74,20 @@ public function __construct(
6974
}
7075

7176
/**
77+
* Is Results Count Enabled
78+
*
7279
* @return bool
7380
*/
7481
public function isResultsCountEnabled()
7582
{
76-
return (bool)$this->scopeConfig->getValue(
83+
return $this->scopeConfig->isSetFlag(
7784
self::CONFIG_RESULTS_COUNT_ENABLED,
7885
ScopeInterface::SCOPE_STORE
7986
);
8087
}
8188

8289
/**
83-
* {@inheritdoc}
90+
* @inheritdoc
8491
*/
8592
public function getItems(QueryInterface $query)
8693
{
@@ -102,6 +109,8 @@ public function getItems(QueryInterface $query)
102109
}
103110

104111
/**
112+
* Return Search Recommendations
113+
*
105114
* @param QueryInterface $query
106115
* @return array
107116
*/
@@ -126,17 +135,21 @@ private function getSearchRecommendations(\Magento\Search\Model\QueryInterface $
126135
}
127136

128137
/**
138+
* Is Search Recommendations Enabled
139+
*
129140
* @return bool
130141
*/
131142
private function isSearchRecommendationsEnabled()
132143
{
133-
return (bool)$this->scopeConfig->getValue(
144+
return $this->scopeConfig->isSetFlag(
134145
self::CONFIG_IS_ENABLED,
135146
ScopeInterface::SCOPE_STORE
136147
);
137148
}
138149

139150
/**
151+
* Return Search Recommendations Count
152+
*
140153
* @return int
141154
*/
142155
private function getSearchRecommendationsCount()

app/code/Magento/CatalogInventory/Model/Configuration.php

Lines changed: 38 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Magento\CatalogInventory\Helper\Minsaleqty as MinsaleqtyHelper;
1010
use Magento\Framework\App\Config\ScopeConfigInterface;
1111
use Magento\Catalog\Model\ProductTypes\ConfigInterface;
12+
use Magento\Store\Model\ScopeInterface;
1213
use Magento\Store\Model\StoreManagerInterface;
1314

1415
/**
@@ -131,6 +132,8 @@ class Configuration implements StockConfigurationInterface
131132
protected $storeManager;
132133

133134
/**
135+
* Configuration constructor.
136+
*
134137
* @param ConfigInterface $config
135138
* @param ScopeConfigInterface $scopeConfig
136139
* @param MinsaleqtyHelper $minsaleqtyHelper
@@ -149,7 +152,7 @@ public function __construct(
149152
}
150153

151154
/**
152-
* {@inheritdoc}
155+
* @inheritdoc
153156
*/
154157
public function getDefaultScopeId()
155158
{
@@ -159,6 +162,8 @@ public function getDefaultScopeId()
159162
}
160163

161164
/**
165+
* Is Qty Type Ids
166+
*
162167
* @param int|null $filter
163168
* @return array
164169
*/
@@ -182,6 +187,8 @@ public function getIsQtyTypeIds($filter = null)
182187
}
183188

184189
/**
190+
* Is Qty
191+
*
185192
* @param int $productTypeId
186193
* @return bool
187194
*/
@@ -201,25 +208,29 @@ public function canSubtractQty($store = null)
201208
{
202209
return $this->scopeConfig->isSetFlag(
203210
self::XML_PATH_CAN_SUBTRACT,
204-
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
211+
ScopeInterface::SCOPE_STORE,
205212
$store
206213
);
207214
}
208215

209216
/**
217+
* Get Min Qty
218+
*
210219
* @param null|string|bool|int|\Magento\Store\Model\Store $store
211220
* @return float
212221
*/
213222
public function getMinQty($store = null)
214223
{
215224
return (float)$this->scopeConfig->getValue(
216225
self::XML_PATH_MIN_QTY,
217-
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
226+
ScopeInterface::SCOPE_STORE,
218227
$store
219228
);
220229
}
221230

222231
/**
232+
* Get Min Sale Qty
233+
*
223234
* @param null|string|bool|int|\Magento\Store\Model\Store $store
224235
* @param int $customerGroupId
225236
* @return float
@@ -230,27 +241,31 @@ public function getMinSaleQty($store = null, $customerGroupId = null)
230241
}
231242

232243
/**
244+
* Get Max Sale Qty
245+
*
233246
* @param null|string|bool|int|\Magento\Store\Model\Store $store
234247
* @return float|null
235248
*/
236249
public function getMaxSaleQty($store = null)
237250
{
238251
return (float)$this->scopeConfig->getValue(
239252
self::XML_PATH_MAX_SALE_QTY,
240-
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
253+
ScopeInterface::SCOPE_STORE,
241254
$store
242255
);
243256
}
244257

245258
/**
259+
* Get Notify Stock Qty
260+
*
246261
* @param null|string|bool|int|\Magento\Store\Model\Store $store
247262
* @return float
248263
*/
249264
public function getNotifyStockQty($store = null)
250265
{
251266
return (float) $this->scopeConfig->getValue(
252267
self::XML_PATH_NOTIFY_STOCK_QTY,
253-
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
268+
ScopeInterface::SCOPE_STORE,
254269
$store
255270
);
256271
}
@@ -264,22 +279,24 @@ public function getNotifyStockQty($store = null)
264279
*/
265280
public function getEnableQtyIncrements($store = null)
266281
{
267-
return (bool) $this->scopeConfig->getValue(
282+
return $this->scopeConfig->isSetFlag(
268283
self::XML_PATH_ENABLE_QTY_INCREMENTS,
269-
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
284+
ScopeInterface::SCOPE_STORE,
270285
$store
271286
);
272287
}
273288

274289
/**
290+
* Get Qty Increments
291+
*
275292
* @param null|string|bool|int|\Magento\Store\Model\Store $store
276293
* @return float
277294
*/
278295
public function getQtyIncrements($store = null)
279296
{
280297
return (float)$this->scopeConfig->getValue(
281298
self::XML_PATH_QTY_INCREMENTS,
282-
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
299+
ScopeInterface::SCOPE_STORE,
283300
$store
284301
);
285302
}
@@ -294,7 +311,7 @@ public function getBackorders($store = null)
294311
{
295312
return (int) $this->scopeConfig->getValue(
296313
self::XML_PATH_BACKORDERS,
297-
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
314+
ScopeInterface::SCOPE_STORE,
298315
$store
299316
);
300317
}
@@ -309,7 +326,7 @@ public function getManageStock($store = null)
309326
{
310327
return (int) $this->scopeConfig->isSetFlag(
311328
self::XML_PATH_MANAGE_STOCK,
312-
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
329+
ScopeInterface::SCOPE_STORE,
313330
$store
314331
);
315332
}
@@ -325,7 +342,7 @@ public function getCanBackInStock($store = null)
325342
{
326343
return $this->scopeConfig->isSetFlag(
327344
self::XML_PATH_CAN_BACK_IN_STOCK,
328-
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
345+
ScopeInterface::SCOPE_STORE,
329346
$store
330347
);
331348
}
@@ -340,7 +357,7 @@ public function isShowOutOfStock($store = null)
340357
{
341358
return $this->scopeConfig->isSetFlag(
342359
self::XML_PATH_SHOW_OUT_OF_STOCK,
343-
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
360+
ScopeInterface::SCOPE_STORE,
344361
$store
345362
);
346363
}
@@ -355,14 +372,13 @@ public function isAutoReturnEnabled($store = null)
355372
{
356373
return $this->scopeConfig->isSetFlag(
357374
self::XML_PATH_ITEM_AUTO_RETURN,
358-
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
375+
ScopeInterface::SCOPE_STORE,
359376
$store
360377
);
361378
}
362379

363380
/**
364-
* Get 'Display product stock status' option value
365-
* Shows if it is necessary to show product stock status ('in stock'/'out of stock')
381+
* Display product stock status. Shows if it is necessary to show product stock status in stock/out of stock.
366382
*
367383
* @param null|string|bool|int|\Magento\Store\Model\Store $store
368384
* @return bool
@@ -371,12 +387,14 @@ public function isDisplayProductStockStatus($store = null)
371387
{
372388
return $this->scopeConfig->isSetFlag(
373389
self::XML_PATH_DISPLAY_PRODUCT_STOCK_STATUS,
374-
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
390+
ScopeInterface::SCOPE_STORE,
375391
$store
376392
);
377393
}
378394

379395
/**
396+
* Get Default Config Value
397+
*
380398
* @param string $field
381399
* @param null|string|bool|int|\Magento\Store\Model\Store $store
382400
* @return string|null
@@ -385,20 +403,22 @@ public function getDefaultConfigValue($field, $store = null)
385403
{
386404
return $this->scopeConfig->getValue(
387405
self::XML_PATH_ITEM . $field,
388-
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
406+
ScopeInterface::SCOPE_STORE,
389407
$store
390408
);
391409
}
392410

393411
/**
412+
* Get Stock Threshold Qty
413+
*
394414
* @param null|string|bool|int|\Magento\Store\Model\Store $store
395415
* @return string|null
396416
*/
397417
public function getStockThresholdQty($store = null)
398418
{
399419
return $this->scopeConfig->getValue(
400420
self::XML_PATH_STOCK_THRESHOLD_QTY,
401-
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
421+
ScopeInterface::SCOPE_STORE,
402422
$store
403423
);
404424
}

app/code/Magento/CatalogInventory/Test/Unit/Model/ConfigurationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public function testGetEnableQtyIncrements()
144144
$store = 1;
145145

146146
$this->scopeConfigMock->expects($this->once())
147-
->method('getValue')
147+
->method('isSetFlag')
148148
->with(
149149
Configuration::XML_PATH_ENABLE_QTY_INCREMENTS,
150150
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,

0 commit comments

Comments
 (0)