diff --git a/_data/sidebars/scos_dev_sidebar.yml b/_data/sidebars/scos_dev_sidebar.yml index 0ea1b123195..19b73cea6d9 100644 --- a/_data/sidebars/scos_dev_sidebar.yml +++ b/_data/sidebars/scos_dev_sidebar.yml @@ -1382,6 +1382,10 @@ entries: url: /docs/scos/dev/feature-integration-guides/glue-api/data-exchange-api/install-the-data-exchange-api.html include_versions: - "202307.0" + - title: Data Exchange API + Inventory Management feature integration + url: /docs/scos/dev/feature-integration-guides/glue-api/dynamic-data-api/install-the-data-exchange-api-inventory-management-feature.md + include_versions: + - "202307.0" - title: Agent Assist url: /docs/scos/dev/feature-integration-guides/agent-assist-feature-integration.html include_versions: diff --git a/_includes/pbc/all/install-features/202400.0/install-the-data-exchange-api-inventory-management-feature.md b/_includes/pbc/all/install-features/202400.0/install-the-data-exchange-api-inventory-management-feature.md new file mode 100644 index 00000000000..39552df01d8 --- /dev/null +++ b/_includes/pbc/all/install-features/202400.0/install-the-data-exchange-api-inventory-management-feature.md @@ -0,0 +1,100 @@ +This document describes how to integrate the Data Exchange API + Inventory Management feature into a Spryker project. + +## Install feature core + +Follow the steps below to install the Data Exchange API + Inventory Management feature core. + +### Prerequisites + +Install the required features: + +| NAME | VERSION | INTEGRATION GUIDE | +|-------------------|------------------|------------------| +| Data Exchange API | {{page.version}} | [Data Exchange API integration](/docs/scos/dev/feature-integration-guides/{{page.version}}/glue-api/dynamic-data-api/data-exchange-api-integration.html) | +| Inventory Management | {{page.version}} | [Install the Inventory Management feature](/docs/pbc/all/warehouse-management-system/202400.0/unified-commerce/install-and-upgrade/install-the-inventory-management-feature.html) | + +### 1) Set up behavior + +Register the following plugins: + +| PLUGIN | SPECIFICATION | PREREQUISITES | NAMESPACE | +|---|---|---|---| +| AvailabilityDynamicEntityPostUpdatePlugin | Checks if `spy_stock_product` is updated and updates availability. | None | Spryker\Zed\Availability\Communication\Plugin\DynamicEntity | +| AvailabilityDynamicEntityPostCreatePlugin | Checks if `spy_stock_product` is updated and updates availability. | None | Spryker\Zed\Availability\Communication\Plugin\DynamicEntity | + +**src/Pyz/Zed/DynamicEntity/DynamicEntityDependencyProvider.php** + +```php + + */ + protected function getDynamicEntityPostUpdatePlugins(): array + { + return [ + new AvailabilityDynamicEntityPostUpdatePlugin(), + ]; + } + + /** + * @return array<\Spryker\Zed\DynamicEntityExtension\Dependency\Plugin\DynamicEntityPostCreatePluginInterface> + */ + protected function getDynamicEntityPostCreatePlugins(): array + { + return [ + new AvailabilityDynamicEntityPostCreatePlugin(), + ]; + } +} +``` + +{% info_block warningBox "Verification" %} + +Let's say you want to have a new endpoint `/dynamic-data/stock-products` to operate with data in `spy_stock_product` table in the database. + +Based on the provided information, the SQL transaction for interacting with the `spy_stock_product` table through the API request via `dynamic-entity/stock-products` would be as follows: + +```sql +BEGIN; +INSERT INTO `spy_dynamic_entity_configuration` VALUES (1,'stock-products','spy_stock_product',1,'{"identifier":"id_stock_product","fields":[{"fieldName":"id_stock_product","fieldVisibleName":"id_stock_product","isCreatable":false,"isEditable":false,"validation":{"isRequired": false},"type":"integer"},{"fieldName":"fk_product","fieldVisibleName":"fk_product","isCreatable":true,"isEditable":true,"type":"integer","validation":{"isRequired": true}},{"fieldName":"fk_stock","fieldVisibleName":"fk_stock","isCreatable":true,"isEditable":true,"type":"integer","validation":{"isRequired": true}},{"fieldName":"is_never_out_of_stock","fieldVisibleName":"is_never_out_of_stock","isCreatable":true,"isEditable":true,"type":"boolean","validation":{"isRequired": false}},{"fieldName":"quantity","fieldVisibleName":"quantity","isCreatable":true,"isEditable":true,"type":"integer","validation":{"isRequired": true}}]}', '2023-07-29 12:15:13.0', '2023-07-29 12:15:15.0'); +COMMIT; +``` + +Do the following: + +1. Obtain an access token. Follow [How to send a request in Data Exchange API](/docs/scos/dev/glue-api-guides/{{page.version}}/data-exchange-api/how-to-guides/how-to-send-request-in-data-exchange-api.html) for details on how to do that. + +2. Send a `PATCH` request. This request needs to include the necessary headers, such as Content-Type, Accept, and Authorization, with the access token provided: + +```bash +PATCH /dynamic-entity/stock-products HTTP/1.1 +Host: glue-backend.mysprykershop.com +Content-Type: application/json +Accept: application/json +Authorization: Bearer {your_token} +Content-Length: 174 +{ + "data": [ + { + "idStockProduct": 1, + "quantity": 10 + } + ] +} +``` + +3. Make sure that after updating the stock data, the product availability is updated as well: +```sql +SELECT * from spy_availability WHERE sku='PRODUCT_SKU'; +``` + +{% endinfo_block %} \ No newline at end of file diff --git a/docs/scos/dev/feature-integration-guides/202307.0/glue-api/data-exchange-api/install-the-data-exchange-api-inventory-management-feature.md b/docs/scos/dev/feature-integration-guides/202307.0/glue-api/data-exchange-api/install-the-data-exchange-api-inventory-management-feature.md new file mode 100644 index 00000000000..864defd3cf7 --- /dev/null +++ b/docs/scos/dev/feature-integration-guides/202307.0/glue-api/data-exchange-api/install-the-data-exchange-api-inventory-management-feature.md @@ -0,0 +1,8 @@ +--- +title: Data Exchange API + Inventory Management feature integration +description: Install the Data Exchange API + Inventory Management features in your project. +last_updated: Sep 06, 2023 +template: feature-integration-guide-template +--- + +{% include pbc/all/install-features/202400.0/install-the-data-exchange-api-inventory-management-feature.md %} \ No newline at end of file