-
Notifications
You must be signed in to change notification settings - Fork 248
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Adapted SourceItem Import/Export to use Source Code instead of SourceId; - Fixed issue when in Stock Sources export process all fields ware excluded; - Fixed type of return value for SourceItem->getSourceId method to int(was string); - Adapted integrational test to the new Export/Import system(with source code).
- Loading branch information
System User
committed
Dec 14, 2017
1 parent
b224061
commit 8548525
Showing
20 changed files
with
241 additions
and
66 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
app/code/Magento/Inventory/Model/Source/Command/GetByCode.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\Inventory\Model\Source\Command; | ||
|
||
use Magento\Framework\Exception\NoSuchEntityException; | ||
use Magento\Inventory\Model\ResourceModel\Source as SourceResourceModel; | ||
use Magento\InventoryApi\Api\Data\SourceInterface; | ||
use Magento\InventoryApi\Api\Data\SourceInterfaceFactory; | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
class GetByCode implements GetByCodeInterface | ||
{ | ||
/** | ||
* @var SourceResourceModel | ||
*/ | ||
private $sourceResource; | ||
|
||
/** | ||
* @var SourceInterfaceFactory | ||
*/ | ||
private $sourceFactory; | ||
|
||
/** | ||
* @param SourceResourceModel $sourceResource | ||
* @param SourceInterfaceFactory $sourceFactory | ||
*/ | ||
public function __construct( | ||
SourceResourceModel $sourceResource, | ||
SourceInterfaceFactory $sourceFactory | ||
) { | ||
$this->sourceResource = $sourceResource; | ||
$this->sourceFactory = $sourceFactory; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function execute(string $code): SourceInterface | ||
{ | ||
/** @var SourceInterface $source */ | ||
$source = $this->sourceFactory->create(); | ||
$this->sourceResource->load($source, $code, SourceInterface::CODE); | ||
|
||
if (null === $source->getSourceId()) { | ||
throw new NoSuchEntityException(__('Source with code "%value" does not exist.', ['value' => $code])); | ||
} | ||
return $source; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
app/code/Magento/Inventory/Model/Source/Command/GetByCodeInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\Inventory\Model\Source\Command; | ||
|
||
use Magento\Framework\Exception\NoSuchEntityException; | ||
use Magento\InventoryApi\Api\Data\SourceInterface; | ||
|
||
/** | ||
* Get Source by code command (Service Provider Interface - SPI) | ||
* | ||
* Separate command interface to which Repository proxies initial Get call, could be considered as SPI - Interfaces | ||
* that you should extend and implement to customize current behaviour, but NOT expected to be used (called) in the code | ||
* of business logic directly | ||
* | ||
* @see \Magento\InventoryApi\Api\SourceRepositoryInterface | ||
* @api | ||
*/ | ||
interface GetByCodeInterface | ||
{ | ||
/** | ||
* Get Source data by given code | ||
* | ||
* @param string $code | ||
* @return SourceInterface | ||
* @throws NoSuchEntityException | ||
*/ | ||
public function execute(string $code): SourceInterface; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.