Skip to content

Commit

Permalink
Merge pull request magento#1194 from magento-engcom/MSI-1192
Browse files Browse the repository at this point in the history
Eliminate dependency on Inventory module on Shipping module
  • Loading branch information
maghamed authored May 22, 2018
2 parents 6bf1db4 + a19a0bc commit 6be7af8
Show file tree
Hide file tree
Showing 12 changed files with 13 additions and 214 deletions.
4 changes: 3 additions & 1 deletion app/code/Magento/Inventory/Model/Source.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
3 changes: 1 addition & 2 deletions app/code/Magento/Inventory/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
1 change: 0 additions & 1 deletion app/code/Magento/Inventory/etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
<item name="code" xsi:type="object">Magento\Inventory\Model\Source\Validator\CodeValidator</item>
<item name="postcode" xsi:type="object">Magento\Inventory\Model\Source\Validator\PostcodeValidator</item>
<item name="country" xsi:type="object">Magento\Inventory\Model\Source\Validator\CountryValidator</item>
<item name="carrier_links" xsi:type="object">Magento\Inventory\Model\Source\Validator\CarrierLinksValidator</item>
</argument>
</arguments>
</type>
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,20 @@ class SourceHydrator
*/
private $dataObjectHelper;

/**
* @var SourceCarrierDataProcessor
*/
private $sourceCarrierDataProcessor;

/**
* @var SourceRegionDataProcessor
*/
private $sourceRegionDataProcessor;

/**
* @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;
}

Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
}
}
1 change: 0 additions & 1 deletion app/code/Magento/InventoryAdminUi/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"magento/framework": "*",
"magento/module-inventory-api": "*",
"magento/module-backend": "*",
"magento/module-shipping": "*",
"magento/module-directory": "*",
"magento/module-ui": "*"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,50 +233,4 @@
</settings>
</field>
</fieldset>
<fieldset name="carriers" sortOrder="40">
<settings>
<label translate="true">Carriers</label>
<collapsible>true</collapsible>
<opened>false</opened>
<dataScope>general</dataScope>
</settings>
<field name="use_default_carrier_config" formElement="checkbox" sortOrder="10">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="default" xsi:type="number">1</item>
</item>
</argument>
<settings>
<label translate="true">Use global Shipping configuration</label>
<dataType>boolean</dataType>
</settings>
<formElements>
<checkbox>
<settings>
<valueMap>
<map name="true" xsi:type="number">1</map>
<map name="false" xsi:type="number">0</map>
</valueMap>
<prefer>toggle</prefer>
</settings>
</checkbox>
</formElements>
</field>
<field name="carrier_codes" formElement="multiselect" sortOrder="20">
<settings>
<label translate="true">Shipping methods</label>
<imports>
<link name="visible">!${$.parentName}.use_default_carrier_config:checked</link>
</imports>
<notice>Use Ctrl+Click for check several values or uncheck value</notice>
</settings>
<formElements>
<multiselect>
<settings>
<options class="Magento\InventoryAdminUi\Model\OptionSource\CarrierSource"/>
</settings>
</multiselect>
</formElements>
</field>
</fieldset>
</form>
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions app/code/Magento/InventoryShipping/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 7 additions & 0 deletions app/code/Magento/InventoryShipping/etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,11 @@
<plugin name="LoadSourceForShipment" type="Magento\InventoryShipping\Plugin\Sales\ResourceModel\Order\Shipment\LoadSourceForShipmentPlugin"/>
<plugin name="DeleteSourceForShipment" type="Magento\InventoryShipping\Plugin\Sales\ResourceModel\Order\Shipment\DeleteSourceForShipmentPlugin"/>
</type>
<type name="Magento\InventoryApi\Model\SourceValidatorChain">
<arguments>
<argument name="validators" xsi:type="array">
<item name="carrier_links" xsi:type="object">Magento\InventoryShipping\Model\Source\Validator\CarrierLinksValidator</item>
</argument>
</arguments>
</type>
</config>

0 comments on commit 6be7af8

Please sign in to comment.