Edit in GitHubLog an issue

Link and unlink stocks and sources

In Admin, you can assign (link) sources to a stock when you create the stock. In REST, creating a stock and assigning sources to it are separate steps.

To link a source to a stock, you must specify the source_code, stock_id, and priority attributes. The priority value indicates where the source ranks in descending order. The Source Selection Algorithm uses this priority order when recommending order fulfillment. All sources linked to a stock are displayed in prioritized order in the Admin.

Service names:

Copied to your clipboard
inventoryApiStockSourceLinksSaveV1
inventoryApiStockSourceLinksDeleteV1
InventoryApiGetStockSourceLinksV1
inventoryApiGetSourcesAssignedToStockOrderedByPriorityV1

REST endpoints:

Copied to your clipboard
POST /V1/inventory/stock-source-links
POST /V1/inventory/stock-source-links-delete
GET /V1/inventory/stock-source-links

StockSourceLink parameters:

NameDescriptionTypeRequirements
stock_id
Stock ID
Integer
Required for POST operations
source_code
Source code of the link
String
Required for POST operations
priority
Priority of the link
Integer
Required when linking a stock to a source

If you specify a sales channel that is already assigned to another stock, Adobe Commerce reassigns the sales channel from the previous stock to the current stock.

Sample usage:

POST <host>/rest/<store_code>/V1/inventory/stock-source-links

Copied to your clipboard
{
"links" : [
{
"source_code" : "central",
"stock_id" : 4,
"priority" : 1
},
{
"source_code" : "east",
"stock_id" : 4,
"priority" : 2
}
]
}

The POST /V1/inventory/stock-source-links-delete endpoint breaks the link between a stock and one or more sources. Commerce does not recalculate priority of sources after you delete links.

Sample Usage:

POST <host>/rest/<store_code>/V1/inventory/stock-source-links-delete

Copied to your clipboard
{
"links" : [
{
"source_code" : "south",
"stock_id" : 4
}
]
}

The following call returns the link information for stock_id = 4.

See Search using REST APIs for information about constructing a search query.

Sample Usage:

GET <host>/rest/<store_code>/V1/inventory/stock-source-links?searchCriteria[filter_groups][0][filters][0][field]=stock_id&searchCriteria[filter_groups][0][filters][0][value]=4&searchCriteria[filter_groups][0][filters][0][condition_type]=eq

Copied to your clipboard
// None

Get sources assigned to a stock

The GET /V1/inventory/get-sources-assigned-to-stock-ordered-by-priority/:stock_id endpoint returns details about each source that is assigned to the specified stock. Manage sources provides definitions for each attribute returned.

Sample Usage:

GET <host>/rest/<store_code>/V1/inventory/get-sources-assigned-to-stock-ordered-by-priority/4

Copied to your clipboard
// None
  • Privacy
  • Terms of Use
  • Do not sell or share my personal information
  • AdChoices
Copyright © 2024 Adobe. All rights reserved.