Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
use Magento\Search\Model\QueryInterface;
use Magento\AdvancedSearch\Model\SuggestedQueriesInterface;

/**
* Class DataProvider
*/
class DataProvider implements SuggestedQueriesInterface
{
/**
Expand Down Expand Up @@ -51,6 +54,8 @@ class DataProvider implements SuggestedQueriesInterface
private $recommendationsFactory;

/**
* DataProvider constructor.
*
* @param ScopeConfigInterface $scopeConfig
* @param \Magento\Catalog\Model\Layer\Resolver $layerResolver
* @param \Magento\AdvancedSearch\Model\ResourceModel\RecommendationsFactory $recommendationsFactory
Expand All @@ -69,18 +74,20 @@ public function __construct(
}

/**
* Is Results Count Enabled
*
* @return bool
*/
public function isResultsCountEnabled()
{
return (bool)$this->scopeConfig->getValue(
return $this->scopeConfig->isSetFlag(
self::CONFIG_RESULTS_COUNT_ENABLED,
ScopeInterface::SCOPE_STORE
);
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function getItems(QueryInterface $query)
{
Expand All @@ -102,6 +109,8 @@ public function getItems(QueryInterface $query)
}

/**
* Return Search Recommendations
*
* @param QueryInterface $query
* @return array
*/
Expand All @@ -126,17 +135,21 @@ private function getSearchRecommendations(\Magento\Search\Model\QueryInterface $
}

/**
* Is Search Recommendations Enabled
*
* @return bool
*/
private function isSearchRecommendationsEnabled()
{
return (bool)$this->scopeConfig->getValue(
return $this->scopeConfig->isSetFlag(
self::CONFIG_IS_ENABLED,
ScopeInterface::SCOPE_STORE
);
}

/**
* Return Search Recommendations Count
*
* @return int
*/
private function getSearchRecommendationsCount()
Expand Down
56 changes: 38 additions & 18 deletions app/code/Magento/CatalogInventory/Model/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Magento\CatalogInventory\Helper\Minsaleqty as MinsaleqtyHelper;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Catalog\Model\ProductTypes\ConfigInterface;
use Magento\Store\Model\ScopeInterface;
use Magento\Store\Model\StoreManagerInterface;

/**
Expand Down Expand Up @@ -131,6 +132,8 @@ class Configuration implements StockConfigurationInterface
protected $storeManager;

/**
* Configuration constructor.
*
* @param ConfigInterface $config
* @param ScopeConfigInterface $scopeConfig
* @param MinsaleqtyHelper $minsaleqtyHelper
Expand All @@ -149,7 +152,7 @@ public function __construct(
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function getDefaultScopeId()
{
Expand All @@ -159,6 +162,8 @@ public function getDefaultScopeId()
}

/**
* Is Qty Type Ids
*
* @param int|null $filter
* @return array
*/
Expand All @@ -182,6 +187,8 @@ public function getIsQtyTypeIds($filter = null)
}

/**
* Is Qty
*
* @param int $productTypeId
* @return bool
*/
Expand All @@ -201,25 +208,29 @@ public function canSubtractQty($store = null)
{
return $this->scopeConfig->isSetFlag(
self::XML_PATH_CAN_SUBTRACT,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
ScopeInterface::SCOPE_STORE,
$store
);
}

/**
* Get Min Qty
*
* @param null|string|bool|int|\Magento\Store\Model\Store $store
* @return float
*/
public function getMinQty($store = null)
{
return (float)$this->scopeConfig->getValue(
self::XML_PATH_MIN_QTY,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
ScopeInterface::SCOPE_STORE,
$store
);
}

/**
* Get Min Sale Qty
*
* @param null|string|bool|int|\Magento\Store\Model\Store $store
* @param int $customerGroupId
* @return float
Expand All @@ -230,27 +241,31 @@ public function getMinSaleQty($store = null, $customerGroupId = null)
}

/**
* Get Max Sale Qty
*
* @param null|string|bool|int|\Magento\Store\Model\Store $store
* @return float|null
*/
public function getMaxSaleQty($store = null)
{
return (float)$this->scopeConfig->getValue(
self::XML_PATH_MAX_SALE_QTY,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
ScopeInterface::SCOPE_STORE,
$store
);
}

/**
* Get Notify Stock Qty
*
* @param null|string|bool|int|\Magento\Store\Model\Store $store
* @return float
*/
public function getNotifyStockQty($store = null)
{
return (float) $this->scopeConfig->getValue(
self::XML_PATH_NOTIFY_STOCK_QTY,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
ScopeInterface::SCOPE_STORE,
$store
);
}
Expand All @@ -264,22 +279,24 @@ public function getNotifyStockQty($store = null)
*/
public function getEnableQtyIncrements($store = null)
{
return (bool) $this->scopeConfig->getValue(
return $this->scopeConfig->isSetFlag(
self::XML_PATH_ENABLE_QTY_INCREMENTS,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
ScopeInterface::SCOPE_STORE,
$store
);
}

/**
* Get Qty Increments
*
* @param null|string|bool|int|\Magento\Store\Model\Store $store
* @return float
*/
public function getQtyIncrements($store = null)
{
return (float)$this->scopeConfig->getValue(
self::XML_PATH_QTY_INCREMENTS,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
ScopeInterface::SCOPE_STORE,
$store
);
}
Expand All @@ -294,7 +311,7 @@ public function getBackorders($store = null)
{
return (int) $this->scopeConfig->getValue(
self::XML_PATH_BACKORDERS,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
ScopeInterface::SCOPE_STORE,
$store
);
}
Expand All @@ -309,7 +326,7 @@ public function getManageStock($store = null)
{
return (int) $this->scopeConfig->isSetFlag(
self::XML_PATH_MANAGE_STOCK,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
ScopeInterface::SCOPE_STORE,
$store
);
}
Expand All @@ -325,7 +342,7 @@ public function getCanBackInStock($store = null)
{
return $this->scopeConfig->isSetFlag(
self::XML_PATH_CAN_BACK_IN_STOCK,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
ScopeInterface::SCOPE_STORE,
$store
);
}
Expand All @@ -340,7 +357,7 @@ public function isShowOutOfStock($store = null)
{
return $this->scopeConfig->isSetFlag(
self::XML_PATH_SHOW_OUT_OF_STOCK,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
ScopeInterface::SCOPE_STORE,
$store
);
}
Expand All @@ -355,14 +372,13 @@ public function isAutoReturnEnabled($store = null)
{
return $this->scopeConfig->isSetFlag(
self::XML_PATH_ITEM_AUTO_RETURN,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
ScopeInterface::SCOPE_STORE,
$store
);
}

/**
* Get 'Display product stock status' option value
* Shows if it is necessary to show product stock status ('in stock'/'out of stock')
* Display product stock status. Shows if it is necessary to show product stock status in stock/out of stock.
*
* @param null|string|bool|int|\Magento\Store\Model\Store $store
* @return bool
Expand All @@ -371,12 +387,14 @@ public function isDisplayProductStockStatus($store = null)
{
return $this->scopeConfig->isSetFlag(
self::XML_PATH_DISPLAY_PRODUCT_STOCK_STATUS,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
ScopeInterface::SCOPE_STORE,
$store
);
}

/**
* Get Default Config Value
*
* @param string $field
* @param null|string|bool|int|\Magento\Store\Model\Store $store
* @return string|null
Expand All @@ -385,20 +403,22 @@ public function getDefaultConfigValue($field, $store = null)
{
return $this->scopeConfig->getValue(
self::XML_PATH_ITEM . $field,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
ScopeInterface::SCOPE_STORE,
$store
);
}

/**
* Get Stock Threshold Qty
*
* @param null|string|bool|int|\Magento\Store\Model\Store $store
* @return string|null
*/
public function getStockThresholdQty($store = null)
{
return $this->scopeConfig->getValue(
self::XML_PATH_STOCK_THRESHOLD_QTY,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
ScopeInterface::SCOPE_STORE,
$store
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public function testGetEnableQtyIncrements()
$store = 1;

$this->scopeConfigMock->expects($this->once())
->method('getValue')
->method('isSetFlag')
->with(
Configuration::XML_PATH_ENABLE_QTY_INCREMENTS,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
Expand Down
Loading