diff --git a/app/code/Magento/Inventory/Model/Source.php b/app/code/Magento/Inventory/Model/Source.php index 91bb7452de924..fb80a5d70a86a 100644 --- a/app/code/Magento/Inventory/Model/Source.php +++ b/app/code/Magento/Inventory/Model/Source.php @@ -288,7 +288,9 @@ public function setFax($fax) */ public function isUseDefaultCarrierConfig() { - return $this->getData(self::USE_DEFAULT_CARRIER_CONFIG); + //TODO: https://github.com/magento-engcom/msi/issues/1192 + //return $this->getData(self::USE_DEFAULT_CARRIER_CONFIG); + return true; } /** diff --git a/app/code/Magento/Inventory/composer.json b/app/code/Magento/Inventory/composer.json index 2d9ede32a4a5b..bc3c8efcb1a59 100644 --- a/app/code/Magento/Inventory/composer.json +++ b/app/code/Magento/Inventory/composer.json @@ -4,8 +4,7 @@ "require": { "php": "~7.1.3||~7.2.0", "magento/framework": "*", - "magento/module-inventory-api": "*", - "magento/module-shipping": "*" + "magento/module-inventory-api": "*" }, "type": "magento2-module", "license": [ diff --git a/app/code/Magento/Inventory/etc/di.xml b/app/code/Magento/Inventory/etc/di.xml index cd225e24ef126..4d26e039b2e82 100644 --- a/app/code/Magento/Inventory/etc/di.xml +++ b/app/code/Magento/Inventory/etc/di.xml @@ -25,7 +25,6 @@ Magento\Inventory\Model\Source\Validator\CodeValidator Magento\Inventory\Model\Source\Validator\PostcodeValidator Magento\Inventory\Model\Source\Validator\CountryValidator - Magento\Inventory\Model\Source\Validator\CarrierLinksValidator diff --git a/app/code/Magento/InventoryAdminUi/Model/OptionSource/CarrierSource.php b/app/code/Magento/InventoryAdminUi/Model/OptionSource/CarrierSource.php deleted file mode 100644 index 3e71861812966..0000000000000 --- a/app/code/Magento/InventoryAdminUi/Model/OptionSource/CarrierSource.php +++ /dev/null @@ -1,58 +0,0 @@ -shippingConfig = $shippingConfig; - } - - /** - * @inheritdoc - */ - public function toOptionArray() - { - if (null === $this->sourceData) { - $carriers = $this->shippingConfig->getAllCarriers(); - foreach ($carriers as $carrier) { - $this->sourceData[] = [ - 'value' => $carrier->getCarrierCode(), - 'label' => $carrier->getConfigData('title'), - ]; - } - } - return $this->sourceData; - } -} diff --git a/app/code/Magento/InventoryAdminUi/Model/Source/SourceCarrierDataProcessor.php b/app/code/Magento/InventoryAdminUi/Model/Source/SourceCarrierDataProcessor.php deleted file mode 100644 index 1b86599e10e17..0000000000000 --- a/app/code/Magento/InventoryAdminUi/Model/Source/SourceCarrierDataProcessor.php +++ /dev/null @@ -1,76 +0,0 @@ -shippingConfig = $shippingConfig; - } - - /** - * @param array $data - * - * @return array - * @throws InputException - */ - public function process(array $data): array - { - $useDefaultCarrierConfig = isset($data[SourceInterface::USE_DEFAULT_CARRIER_CONFIG]) - && true === (bool)$data[SourceInterface::USE_DEFAULT_CARRIER_CONFIG]; - - if (false === $useDefaultCarrierConfig - && isset($data['carrier_codes']) - && is_array($data['carrier_codes']) - ) { - $data[SourceInterface::CARRIER_LINKS] = $this->getCarrierLinksData($data['carrier_codes']); - } else { - $data[SourceInterface::CARRIER_LINKS] = []; - } - unset($data['carrier_codes']); - - return $data; - } - - /** - * @param array $carrierCodes - * - * @return array - */ - private function getCarrierLinksData(array $carrierCodes): array - { - $carrierLinks = []; - foreach ($carrierCodes as $carrierCode) { - $carrierLinks[] = [ - SourceCarrierLinkInterface::CARRIER_CODE => $carrierCode, - ]; - } - return $carrierLinks; - } -} diff --git a/app/code/Magento/InventoryAdminUi/Model/Source/SourceHydrator.php b/app/code/Magento/InventoryAdminUi/Model/Source/SourceHydrator.php index 3f8963a10071e..6a3ec18603706 100644 --- a/app/code/Magento/InventoryAdminUi/Model/Source/SourceHydrator.php +++ b/app/code/Magento/InventoryAdminUi/Model/Source/SourceHydrator.php @@ -22,11 +22,6 @@ class SourceHydrator */ private $dataObjectHelper; - /** - * @var SourceCarrierDataProcessor - */ - private $sourceCarrierDataProcessor; - /** * @var SourceRegionDataProcessor */ @@ -34,16 +29,13 @@ class SourceHydrator /** * @param DataObjectHelper $dataObjectHelper - * @param SourceCarrierDataProcessor $sourceCarrierDataProcessor * @param SourceRegionDataProcessor $sourceRegionDataProcessor */ public function __construct( DataObjectHelper $dataObjectHelper, - SourceCarrierDataProcessor $sourceCarrierDataProcessor, SourceRegionDataProcessor $sourceRegionDataProcessor ) { $this->dataObjectHelper = $dataObjectHelper; - $this->sourceCarrierDataProcessor = $sourceCarrierDataProcessor; $this->sourceRegionDataProcessor = $sourceRegionDataProcessor; } @@ -55,7 +47,6 @@ public function __construct( */ public function hydrate(SourceInterface $source, array $data): SourceInterface { - $data['general'] = $this->sourceCarrierDataProcessor->process($data['general']); $data['general'] = $this->sourceRegionDataProcessor->process($data['general']); $this->dataObjectHelper->populateWithArray($source, $data['general'], SourceInterface::class); diff --git a/app/code/Magento/InventoryAdminUi/Ui/DataProvider/SourceDataProvider.php b/app/code/Magento/InventoryAdminUi/Ui/DataProvider/SourceDataProvider.php index 13b9065f0f85a..fb9fe147bf105 100644 --- a/app/code/Magento/InventoryAdminUi/Ui/DataProvider/SourceDataProvider.php +++ b/app/code/Magento/InventoryAdminUi/Ui/DataProvider/SourceDataProvider.php @@ -94,7 +94,6 @@ public function getData() if ($data['totalRecords'] > 0) { $sourceCode = $data['items'][0][SourceInterface::SOURCE_CODE]; $sourceGeneralData = $data['items'][0]; - $sourceGeneralData['carrier_codes'] = $this->getAssignedCarrierCodes($sourceCode); $sourceGeneralData['disable_source_code'] = !empty($sourceGeneralData['source_code']); $dataForSingle[$sourceCode] = [ 'general' => $sourceGeneralData, @@ -129,22 +128,4 @@ public function getSearchResult() ); return $searchResult; } - - /** - * @param string $sourceCode - * @return array - */ - private function getAssignedCarrierCodes(string $sourceCode): array - { - $source = $this->sourceRepository->get($sourceCode); - $carrierCodes = []; - - $carrierLinks = $source->getCarrierLinks(); - if (count($carrierLinks)) { - foreach ($carrierLinks as $carrierLink) { - $carrierCodes[] = $carrierLink->getCarrierCode(); - } - } - return $carrierCodes; - } } diff --git a/app/code/Magento/InventoryAdminUi/composer.json b/app/code/Magento/InventoryAdminUi/composer.json index e8b4779f88937..ec77429029738 100644 --- a/app/code/Magento/InventoryAdminUi/composer.json +++ b/app/code/Magento/InventoryAdminUi/composer.json @@ -6,7 +6,6 @@ "magento/framework": "*", "magento/module-inventory-api": "*", "magento/module-backend": "*", - "magento/module-shipping": "*", "magento/module-directory": "*", "magento/module-ui": "*" }, diff --git a/app/code/Magento/InventoryAdminUi/view/adminhtml/ui_component/inventory_source_form.xml b/app/code/Magento/InventoryAdminUi/view/adminhtml/ui_component/inventory_source_form.xml index 045b7cd32ca93..a1df10acdaa1b 100644 --- a/app/code/Magento/InventoryAdminUi/view/adminhtml/ui_component/inventory_source_form.xml +++ b/app/code/Magento/InventoryAdminUi/view/adminhtml/ui_component/inventory_source_form.xml @@ -233,50 +233,4 @@ -
- - - true - false - general - - - - - 1 - - - - - boolean - - - - - - 1 - 0 - - toggle - - - - - - - - - !${$.parentName}.use_default_carrier_config:checked - - Use Ctrl+Click for check several values or uncheck value - - - - - - - - - -
diff --git a/app/code/Magento/Inventory/Model/Source/Validator/CarrierLinksValidator.php b/app/code/Magento/InventoryShipping/Model/Source/Validator/CarrierLinksValidator.php similarity index 97% rename from app/code/Magento/Inventory/Model/Source/Validator/CarrierLinksValidator.php rename to app/code/Magento/InventoryShipping/Model/Source/Validator/CarrierLinksValidator.php index 6e83f8ca51798..b27ba85975072 100644 --- a/app/code/Magento/Inventory/Model/Source/Validator/CarrierLinksValidator.php +++ b/app/code/Magento/InventoryShipping/Model/Source/Validator/CarrierLinksValidator.php @@ -5,7 +5,7 @@ */ declare(strict_types=1); -namespace Magento\Inventory\Model\Source\Validator; +namespace Magento\InventoryShipping\Model\Source\Validator; use Magento\Framework\Validation\ValidationResult; use Magento\Framework\Validation\ValidationResultFactory; diff --git a/app/code/Magento/InventoryShipping/composer.json b/app/code/Magento/InventoryShipping/composer.json index fbc10f57d64c3..cc17edb3fe246 100644 --- a/app/code/Magento/InventoryShipping/composer.json +++ b/app/code/Magento/InventoryShipping/composer.json @@ -10,6 +10,7 @@ "magento/module-inventory-sales-api": "*", "magento/module-inventory-source-selection-api": "*", "magento/module-sales": "*", + "magento/module-shipping": "*", "magento/module-store": "*" }, "type": "magento2-module", diff --git a/app/code/Magento/InventoryShipping/etc/di.xml b/app/code/Magento/InventoryShipping/etc/di.xml index affdba495c4f2..d432ca79af77e 100644 --- a/app/code/Magento/InventoryShipping/etc/di.xml +++ b/app/code/Magento/InventoryShipping/etc/di.xml @@ -17,4 +17,11 @@ + + + + Magento\InventoryShipping\Model\Source\Validator\CarrierLinksValidator + + +