12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <?php
- /**
- * Copyright © Magento, Inc. All rights reserved.
- * See COPYING.txt for license details.
- */
- declare(strict_types=1);
- namespace Magento\InventoryConfiguration\Model;
- use Magento\InventoryConfigurationApi\Model\IsSourceItemManagementAllowedForProductTypeInterface;
- use Magento\InventoryCatalogApi\Model\GetProductTypesBySkusInterface;
- use Magento\InventoryConfigurationApi\Model\IsSourceItemManagementAllowedForSkuInterface;
- class IsSourceItemManagementAllowedForSku implements IsSourceItemManagementAllowedForSkuInterface
- {
- /**
- * @var GetProductTypesBySkusInterface
- */
- private $getProductTypesBySkus;
- /**
- * @var IsSourceItemManagementAllowedForProductTypeInterface
- */
- private $isSourceItemManagementAllowedForProductType;
- /**
- * @param GetProductTypesBySkusInterface $getProductTypesBySkus
- * @param IsSourceItemManagementAllowedForProductTypeInterface $isSourceItemManagementAllowedForProductType
- */
- public function __construct(
- GetProductTypesBySkusInterface $getProductTypesBySkus,
- IsSourceItemManagementAllowedForProductTypeInterface $isSourceItemManagementAllowedForProductType
- ) {
- $this->getProductTypesBySkus = $getProductTypesBySkus;
- $this->isSourceItemManagementAllowedForProductType = $isSourceItemManagementAllowedForProductType;
- }
- /**
- * @inheritdoc
- */
- public function execute(string $sku): bool
- {
- $productType = $this->getProductTypesBySkus->execute([$sku]);
- if (isset($productType[$sku])) {
- $typeId = $productType[$sku];
- } else {
- return false;
- }
- return $this->isSourceItemManagementAllowedForProductType->execute($typeId);
- }
- }
|