forked from magento/magento2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request magento#1077 from magento-engcom/793
MSI-793: Incorrect process of Out-of-Stock Threshold
- Loading branch information
Showing
7 changed files
with
262 additions
and
128 deletions.
There are no files selected for viewing
68 changes: 0 additions & 68 deletions
68
app/code/Magento/InventoryCatalog/Model/ResourceModel/SetDataToLegacyStockStatus.php
This file was deleted.
Oops, something went wrong.
74 changes: 74 additions & 0 deletions
74
app/code/Magento/InventoryCatalog/Model/SourceItem/SourceItemsSave.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,74 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\InventoryCatalog\Model\SourceItem; | ||
|
||
use Magento\Framework\Exception\CouldNotSaveException; | ||
use Magento\Framework\Exception\InputException; | ||
use Magento\Framework\Validation\ValidationException; | ||
use Magento\Inventory\Model\ResourceModel\SourceItem\SaveMultiple; | ||
use Magento\Inventory\Model\SourceItem\Validator\SourceItemsValidator; | ||
use Magento\InventoryApi\Api\SourceItemsSaveInterface; | ||
use Psr\Log\LoggerInterface; | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
class SourceItemsSave implements SourceItemsSaveInterface | ||
{ | ||
/** | ||
* @var SourceItemsValidator | ||
*/ | ||
private $sourceItemsValidator; | ||
|
||
/** | ||
* @var SaveMultiple | ||
*/ | ||
private $saveMultiple; | ||
|
||
/** | ||
* @var LoggerInterface | ||
*/ | ||
private $logger; | ||
|
||
/** | ||
* @param SourceItemsValidator $sourceItemsValidator | ||
* @param SaveMultiple $saveMultiple | ||
* @param LoggerInterface $logger | ||
*/ | ||
public function __construct( | ||
SourceItemsValidator $sourceItemsValidator, | ||
SaveMultiple $saveMultiple, | ||
LoggerInterface $logger | ||
) { | ||
$this->sourceItemsValidator = $sourceItemsValidator; | ||
$this->saveMultiple = $saveMultiple; | ||
$this->logger = $logger; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function execute(array $sourceItems) | ||
{ | ||
if (empty($sourceItems)) { | ||
throw new InputException(__('Input data is empty')); | ||
} | ||
|
||
$validationResult = $this->sourceItemsValidator->validate($sourceItems); | ||
if (!$validationResult->isValid()) { | ||
throw new ValidationException(__('Validation Failed'), null, 0, $validationResult); | ||
} | ||
|
||
try { | ||
$this->saveMultiple->execute($sourceItems); | ||
} catch (\Exception $e) { | ||
$this->logger->error($e->getMessage()); | ||
throw new CouldNotSaveException(__('Could not save Source Item'), $e); | ||
} | ||
} | ||
} |
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.