forked from kiwicommerce/magento2-inventory-log
-
Notifications
You must be signed in to change notification settings - Fork 12
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 #18 from reense/feature/webapi-support
Added support for stock updates via REST api
- Loading branch information
Showing
5 changed files
with
45 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
namespace Elgentos\InventoryLog\Plugin\Webapi\Stock; | ||
|
||
class StockItemRepository | ||
{ | ||
public function __construct( | ||
public \Magento\Framework\Registry $registry, | ||
public \Elgentos\InventoryLog\Helper\Data $helper | ||
) {} | ||
|
||
public function beforeSave( | ||
$subject, | ||
\Magento\CatalogInventory\Api\Data\StockItemInterface $stockItem | ||
): array { | ||
if (!$this->helper->isModuleEnabled()) { | ||
return [$stockItem]; | ||
} | ||
|
||
$this->registry->register( | ||
\Elgentos\InventoryLog\Helper\Data::MOVEMENT_SECTION, | ||
\Elgentos\InventoryLog\Helper\Data::WEBAPI_STOCK_UPDATE | ||
); | ||
|
||
return [$stockItem]; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0"?> | ||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> | ||
<type name="Magento\CatalogInventory\Model\Stock\StockItemRepository"> | ||
<plugin name="update_stockitem_via_webapi" type="Elgentos\InventoryLog\Plugin\Webapi\Stock\StockItemRepository" | ||
sortOrder="1" | ||
disabled="false"/> | ||
</type> | ||
</config> |