Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
module-inventory-catalog
Model
IsSingleSourceMode.php
Go to the documentation of this file.
1
<?php
6
declare(strict_types=1);
7
8
namespace
Magento\InventoryCatalog\Model
;
9
10
use
Magento\Framework\Api\SearchCriteriaBuilder
;
11
use
Magento\InventoryApi\Api\Data\SourceInterface
;
12
use
Magento\InventoryApi\Api\SourceRepositoryInterface
;
13
use
Magento\InventoryCatalogApi\Model\IsSingleSourceModeInterface
;
14
18
class
IsSingleSourceMode
implements
IsSingleSourceModeInterface
19
{
23
private
$searchCriteriaBuilder;
24
28
private
$sourceRepository;
29
34
public
function
__construct
(
35
SourceRepositoryInterface
$sourceRepository,
36
SearchCriteriaBuilder
$searchCriteriaBuilder
37
) {
38
$this->sourceRepository =
$sourceRepository
;
39
$this->searchCriteriaBuilder =
$searchCriteriaBuilder
;
40
}
41
45
public
function
execute
(): bool
46
{
47
$searchCriteria
= $this->searchCriteriaBuilder
48
->addFilter(
SourceInterface::ENABLED
,
true
)
49
->create();
50
51
$searchResult = $this->sourceRepository->getList(
$searchCriteria
);
52
return
$searchResult->getTotalCount() < 2;
53
}
54
}
Magento\Framework\Api\SearchCriteriaBuilder
Definition:
SearchCriteriaBuilder.php:14
Magento\InventoryCatalog\Model\IsSingleSourceMode\__construct
__construct(SourceRepositoryInterface $sourceRepository, SearchCriteriaBuilder $searchCriteriaBuilder)
Definition:
IsSingleSourceMode.php:34
$searchCriteria
$searchCriteria
Definition:
order_rollback.php:16
Magento\InventoryCatalogApi\Model\IsSingleSourceModeInterface
Definition:
IsSingleSourceModeInterface.php:15
Magento\InventoryCatalog\Model\IsSingleSourceMode
Definition:
IsSingleSourceMode.php:18
Magento\InventoryCatalog\Model\IsSingleSourceMode\execute
execute()
Definition:
IsSingleSourceMode.php:45
Magento\InventoryApi\Api\Data\SourceInterface
Definition:
SourceInterface.php:17
Magento\InventoryApi\Api\SourceRepositoryInterface
Definition:
SourceRepositoryInterface.php:29
$searchCriteriaBuilder
$searchCriteriaBuilder
Definition:
order_rollback.php:15
Magento\InventoryApi\Api\Data\SourceInterface\ENABLED
const ENABLED
Definition:
SourceInterface.php:26
Magento\InventoryCatalog\Model
Definition:
BulkInventoryTransfer.php:8
$sourceRepository
$sourceRepository
Definition:
source.php:20