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.
- Add arround plugin listen to reservations append function
- Loading branch information
larsroettig
committed
Oct 29, 2017
1 parent
307de4f
commit dece474
Showing
2 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
74 changes: 74 additions & 0 deletions
74
app/code/Magento/InventoryCatalog/Plugin/Model/LegacyCatalogInventoryPlugin.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 | ||
/** | ||
* Created by PhpStorm. | ||
* User: roettigl | ||
* Date: 29.10.17 | ||
* Time: 15:24 | ||
*/ | ||
|
||
namespace Magento\InventoryCatalog\Plugin\Model; | ||
|
||
use Magento\Framework\App\ResourceConnection; | ||
use Magento\InventoryApi\Api\Data\ReservationInterface; | ||
use Magento\InventoryApi\Api\ReservationsAppendInterface; | ||
|
||
/** | ||
* Plugin help to fill the legacy catalog inventory tables cataloginventory_stock_status and | ||
* cataloginventory_stock_item to don't break the backward compatible. | ||
*/ | ||
class LegacyCatalogInventoryPlugin | ||
{ | ||
|
||
/** | ||
* @var ResourceConnection | ||
*/ | ||
private $resourceConnection; | ||
|
||
/** | ||
* @param ResourceConnection $resourceConnection | ||
*/ | ||
public function __construct(ResourceConnection $resourceConnection) | ||
{ | ||
$this->resourceConnection = $resourceConnection; | ||
} | ||
|
||
/** | ||
* Plugin method to fill the legacy tables. | ||
* | ||
* @param ReservationsAppendInterface $subject | ||
* @param callable $callable | ||
* @param ReservationInterface[] $reservations | ||
* @return mixed | ||
* @see ReservationsAppendInterface::execute | ||
* @SuppressWarnings(PHPMD.UnusedFormalParameter) | ||
*/ | ||
public function aroundExecute(ReservationsAppendInterface $subject, callable $callable, array $reservations) | ||
{ | ||
$result = $callable($reservations); | ||
$this->updateStockItemTable($reservations); | ||
$this->updateStockStatusTable($reservations); | ||
return $result; | ||
} | ||
|
||
/** | ||
* Update cataloginventory_stock_item qty with reservation information. | ||
* | ||
* @param ReservationInterface[] $reservations | ||
* @return void | ||
*/ | ||
private function updateStockItemTable(array $reservations) | ||
{ | ||
// @todo impelemention reqiured | ||
} | ||
|
||
/** | ||
* Update cataloginventory_stock_status qty with reservation information. | ||
* | ||
* @param ReservationInterface[] $reservations | ||
* @return void | ||
*/ | ||
private function updateStockStatusTable(array $reservations) | ||
{ | ||
// @todo impelemention reqiured | ||
} | ||
} |
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