Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

Update MSI REST tutorial #3294

Merged
merged 3 commits into from
Nov 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion _data/toc/rest-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ pages:
url: /rest/tutorials/orders/order-intro.html
include_versions: ["2.1", "2.2", "2.3"]

- label: Order processing with MSI
- label: Order processing with Inventory Management
class: tutorial
url: /rest/tutorials/msi-order-processing/index.html
include_versions: ["2.3"]
Expand Down
2 changes: 1 addition & 1 deletion guides/v2.3/rest/tutorials/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ The REST tutorials provide an introduction to Magento web APIs. In general, the

* The [**order processing** tutorial]({{ page.baseurl }}/rest/tutorials/orders/order-intro.html) demonstrates the lifecycle of an order. Major steps include creating a quote, converting it to an order, issuing an invoice, and shipping the order.

* The [**order processing with MSI**]({{ page.baseurl }}/rest/tutorials/msi-order-processing/index.html) tutorial builds upon the original order processing tutorial. It also configures sources and stocks and other Multi Source Inventory features.
* The [**order processing with Inventory Management**]({{ page.baseurl }}/rest/tutorials/msi-order-processing/index.html) tutorial builds upon the original order processing tutorial. It also configures sources and stocks and other Inventory Management features.

* The [**configurable product** tutorial]({{ page.baseurl }}/rest/tutorials/configurable-product/config-product-intro.html) helps you plan then create a configurable product and its component simple products.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
layout: tutorial
group: rest-api
title: Step 4. Link stocks and sources
subtitle: Order processing with MSI
subtitle: Order processing with Inventory Management
menu_title: Step 4. Link stocks and sources
menu_order: 40
level3_subgroup: msi-tutorial
Expand All @@ -15,7 +15,7 @@ functional_areas:

This step links the sources we created in Step 2 with the stocks we created in Step 3.

Each stock can be assigned one or more sources. MSI uses these associations to calculate the virtual aggregated inventory per product.
Each stock can be assigned one or more sources. Magento uses these associations to calculate the virtual aggregated inventory per product.

{:.bs-callout .bs-callout-tip}
You must reindex and flush cache after performing this step.
Expand Down Expand Up @@ -96,7 +96,7 @@ Magento returns empty array.
**Required:** After you have assigned a source to stock, use the following command to perform a full reindex and flush the cache. This is required!

``` bash
php bin/magento indexer:reindex && php bin/magento cache:flush
bin/magento indexer:reindex && bin/magento cache:flush
```

### Verify this step
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
---
layout: tutorial
group: rest-api
title: Step 13. Bulk transfer products
subtitle: Order processing with Inventory Management
menu_title: Step 13. Bulk transfer products
menu_order: 130
level3_subgroup: msi-tutorial
return_to:
title: REST Tutorials
url: rest/tutorials/index.html
functional_areas:
- Integration
---

The Driven Backpacks (`24-WB03`) have sold well in the United States, but not in Europe. The Baltimore and Austin warehouses are out of stock. In this step, we'll bulk transfer all of Berlin's stock for this product to Baltimore, and all of Frankfurt's stock to Austin. As a result, the product cannot be shipped from either European source.

In this scenario, there are no pending orders that contain the product, nor is the product on back-order. In production, make sure that you fulfill any pending orders before you bulk transfer a product. You might want to remove the product from the European website before performing the bulk transfer.

## Bulk transfer the product from Berlin to Baltimore

The `POST /V1/inventory/bulk-product-source-transfer` endpoint allows you to specify an array of SKUs to bulk transfer from one source to another, but this example includes only one SKU. If you set the `unassignFromOrigin` attribute to `true`, the origin source is no longer associated with the specified products. If the attribute is `false`, Magento designates the products as being out of stock at the origin source with a quantity of 0.

**Endpoint**

`POST http://<host>/rest/all/V1/inventory/bulk-product-source-transfer`

**Scope**

`all` store views

**Headers**

`Content-Type`: `application/json`

`Authorization`: `Bearer <admin_token>`

**Payload**

``` json
{
"skus": [
"24-WB03"
],
"originSource": "berlin_wh",
"destinationSource": "baltimore_wh",
"unassignFromOrigin": true
}
```

**Response**

`true`

## Bulk transfer the product from Frankfurt to Austin

Use the same endpoint to bulk transfer the product to Austin.

**Payload**

``` json
{
"skus": [
"24-WB03"
],
"originSource": "frankfurt_wh",
"destinationSource": "austin_wh",
"unassignFromOrigin": true
}
```

**Response**

`true`

## Verify this step

In Admin, click **Catalog** > **Products**. Scroll down to the Driven Backpack row.

* The stock has been transferred from Berlin to Baltimore. The Baltimore warehouse now has 32 units.
* The Austin warehouse now has 7 units.
* The **Salable Quantity** column no longer lists European stock.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
layout: tutorial
title: Step 1. Configure your environment
subtitle: Order processing with MSI
subtitle: Order processing with Inventory Management
menu_title: Step 1. Configure your environment
menu_order: 10
level3_subgroup: msi-tutorial
Expand All @@ -12,11 +12,11 @@ functional_areas:
- Integration
---

This step guides you through the process of configuring your Magento instance so that you can perform the Order Processing with MSI tutorial.
This step guides you through the process of configuring your Magento instance so that you can perform the Order Processing with Inventory Management tutorial.

## Create two websites

**Sales Channels** are entities from which you sell inventory. You can set up Magento websites to be sales channels, and MSI supports extensions for creating other types of channels.
**Sales Channels** are entities from which you sell inventory. You can set up Magento websites to be sales channels, and Magento supports extensions for creating other types of channels.

In this tutorial, we'll create the infrastructure needed to implement a US and a German store.

Expand Down Expand Up @@ -83,7 +83,7 @@ In this tutorial, we'll create the infrastructure needed to implement a US and a
3. Click **Create Store View** and assign the following values:

Field | Value
--- | ---
--- | ---
Store | Europe Store
Name | Germany Store View
Code | `de`
Expand Down Expand Up @@ -117,7 +117,7 @@ For this tutorial, we'll assume that payment and shipping methods are configured
**Required:** Perform a full reindex and flush the cache.

``` bash
php bin/magento indexer:reindex && php bin/magento cache:flush
bin/magento indexer:reindex && php bin/magento cache:flush
```

## Verify this step
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
layout: tutorial
title: Step 8. Create a cart and add products to it
subtitle: Order processing with MSI
menu_title: Step 8. Create a cart and add products to it
menu_order: 80
title: Step 7. Create a cart and add products to it
subtitle: Order processing with Inventory Management
menu_title: Step 7. Create a cart and add products to it
menu_order: 70
level3_subgroup: msi-tutorial
return_to:
title: REST Tutorials
Expand All @@ -12,7 +12,7 @@ functional_areas:
- Integration
---

Next, we'll create a cart and add the items that we created in [Step 5. Create products](create-products.html).
Next, we'll create a cart and add the items that we modified in [Reassign products to custom sources](reassign-products-to-another-source.html.

## Create a cart

Expand All @@ -38,27 +38,27 @@ None

**Response**

The response is the `quoteId`: 3
The response is the `quoteId`: 4

## Check for product availability

In [Step 6. Reassign products to another source](reassign-products-to-another-source.html), we defined the quantities of products `sp1` and `sp2` for the UK source as follows:
In [Step 6. Reassign products to another source](reassign-products-to-another-source.html), we defined the quantities of products `24-WB01` and `24-WB03` for the US source as follows:

Product | Baltimore Warehouse | Austin Warehouse | Reno Warehouse
--- | --- | --- | ---
`sp1` | 50 | 10 | 100
`sp2` | 25 | 0 | 50
`24-WB01` | 35 | 10 | 25
`24-WB03` | 19 | 0 | 42
{:style="table-layout:auto;"}

Later in this step, we'll order 20 `sp1` items and 60 `sp2` items. We can see that we have enough salable items for both products, but let's check programmatically.
Later in this step, we'll order 20 `24-WB01` items and 50 `24-WB03` items. We can see that we have enough salable items for both products, but let's check programmatically.

### Check for product `sp1`
### Check for product `24-WB01`

The `get-product-salable-quantity` endpoint indicates how many items are available for sale for the specified product and source.
The `get-product-salable-quantity` endpoint indicates how many items are available for sale for the specified product (24-WB01) and source (2).

**Endpoint**

`GET http://<host>rest/us/V1/inventory/get-product-salable-quantity/sp1/2`
`GET http://<host>rest/us/V1/inventory/get-product-salable-quantity/24-WB01/2`

**Scope**

Expand All @@ -76,15 +76,15 @@ Not applicable

**Response**

`160`
`70`

### Check for product `sp2`
### Check for product `24-WB03`

Use the same endpoint to check the quantity available for product `sp2`.
Use the same endpoint to check the quantity available for product `24-WB03`.

**Endpoint**

`GET http://<host>rest/us/V1/inventory/get-product-salable-quantity/sp2/2`
`GET http://<host>rest/us/V1/inventory/get-product-salable-quantity/24-WB03/2`

**Scope**

Expand All @@ -102,15 +102,15 @@ Not applicable

**Response**

`75`
`61`

## Add items to the cart

We have ensured that we have enough physical products in stock to fulfill the potential order.

### Add the first simple product

In this call, we'll add 20 `sp1` items. This portion of the order can be fulfilled from the Baltimore or Reno warehouse.
In this call, we'll add 20 `24-WB01` items. This portion of the order can be fulfilled from the Baltimore or Reno warehouse.

**Endpoint**

Expand All @@ -131,9 +131,9 @@ In this call, we'll add 20 `sp1` items. This portion of the order can be fulfill
``` json
{
"cartItem": {
"sku": "sp1",
"sku": "24-WB01",
"qty": 20,
"quote_id": "3"
"quote_id": "4"
}
}
```
Expand All @@ -144,56 +144,59 @@ Note the `item_id` for use in subsequent steps.

``` json
{
"item_id": 5,
"sku": "sp1",
"item_id": 3,
"sku": "24-WB01",
"qty": 20,
"name": "Simple Product 1",
"name": "Voyage Yoga Bag",
"product_type": "simple",
"quote_id": "3"
"quote_id": "4"
}
```

### Add the second simple product

Use the same endpoint to add 60 items of `sp2` to the cart. Multiple sources will be required to fulfill this potential order.
Use the same endpoint to add 50 items of `24-WB03` to the cart. Multiple sources will be required to fulfill this potential order.

**Payload**

``` json
{
"cartItem": {
"sku": "sp2",
"qty": 60,
"quote_id": "3"
"sku": "24-WB03",
"qty": 50,
"quote_id": "4"
}
}
```
**Response**

Note the `item_id` for use in subsequent steps.


``` json
{
"item_id": 6,
"sku": "sp2",
"qty": 60,
"name": "Simple Product 2",
"price": 10,
"item_id": 4,
"sku": "24-WB03",
"qty": 50,
"name": "Driven Backpack",
"price": 36,
"product_type": "simple",
"quote_id": "3"
"quote_id": "4"
}
```

### Add a virtual product
### Add a downloadable product

Finally, we'll add a single instance of a virtual product to the cart.
Finally, we'll add a single instance of a downloadable product to the cart.

**Payload**

``` json
{
"cartItem": {
"sku": "vp1",
"sku": "240-LV06",
"qty": 1,
"quote_id": "3"
"quote_id": "4"
}
}
```
Expand All @@ -202,13 +205,22 @@ Finally, we'll add a single instance of a virtual product to the cart.

``` json
{
"item_id": 7,
"sku": "vp1",
"item_id": 5,
"sku": "240-LV06",
"qty": 1,
"name": "Gold Club Membership",
"price": 20,
"product_type": "virtual",
"quote_id": "3"
"name": "Yoga Adventure",
"price": 22,
"product_type": "downloadable",
"quote_id": "4",
"product_option": {
"extension_attributes": {
"downloadable_option": {
"downloadable_links": [
3
]
}
}
}
}
```

Expand Down
Loading