Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

This api is used for updating stock status of product via sku list.

...

1. Get admin token

Using for authentication, we need token from an admin with roles allowed for Magento_Catalog::products or admin user with all resources.

Image ModifiedApi Call:

  • End Point: /V1/integration/admin/token (example: https://eztoro.com/rest/V1/integration/admin/token)
  • Method: POST
  • Authentication: None
  • Parameters: username (Admin username) and password (Admin user password)

Image Modified

For more information, please read more in this link (Magento token-based authentication).

Notes: Admin token has expiration time or being clear in admin portal, afterthat you need to get new token for all usages.


2. Update stock status

This api allow user to update stock status of product in Magento with specified skus list.

  • End Point: /V1/products/status/update (example: https://eztoro.com/rest/V1/products/status/update)
  • Method: POST
  • Authentication: Bearer Token
  • Parameters:
    • skus: List sku for update, using in array
    • status: Status that need to update. Accepted Value: 1 (Available) or 0 (Not Available)

Image Modified

Image Modified

3. API Response:

  • success: Result of api request (true or false).
  • updated_successful_items: Number of successfully updated items.
  • updated_fail_items: Number of unsuccessfully updated items.
  • message: Message.
  • failed_skus: List of unsuccessfully updated sku.
  • errors: Detail of error messages.


4. Exception Message:

  • SKU_INVALID - One or more sku is invalid or not found.
  • INPUT_INVALID - One or more input exceptions have occurred.
  • INVALID_FIELD_RANGE - The %fieldName value of "%value" must be between %minValue and %maxValue
  • INVALID_FIELD_MIN_VALUE - The %fieldName value of "%value" must be greater than or equal to %minValue.
  • INVALID_FIELD_MAX_VALUE - The %fieldName value of "%value" must be less than or equal to %maxValue.
  • INVALID_FIELD_VALUE - Invalid value of "%value" provided for the %fieldName field.
  • REQUIRED_FIELD - "%fieldName" is required. Enter and try again.

API - Update Product Quantity

  • Get admin token: follow the steps above.

The api support updating product quantity on specified source

  • Select the source you want to update

Stores > Settings > Configuration > Catalog > Inventory

Image Removed

  • Update product Quantity

  • End Point: /V1/products/status/update (example: https://eztoro.com/rest/V1/products/status/update)
  • Method: POST
  • Authentication: Bearer Token
  • Parameters:
    • items: product listing
      • sku: product sku, using string
      • qty: product quantity that need to update, using numeric

Image Removed

Image Removed

Api Response:

  • success: Result of api request (true or false)
  • updated_successful_items: Number of successfully updated items
  • updated_fail_items: Number of unsuccessfully updated items
  • message: Message
  • failed_skus: List of unsuccessfully updated sku
  • failed_items: Input data or items is invalid 
  • errors: Detail of error messages

Exception Message:

  • SKU_INVALID - One or more sku is invalid or not found
  • PRODUCT_TYPE_INVALID - One or more items cannot add quantity
  • INPUT_INVALID - Input data is invalid
  • INVALID_FIELD_RANGE - The %fieldName value of "%value" must be between %minValue and %maxValue
  • INVALID_FIELD_MIN_VALUE - The %fieldName value of "%value" must be greater than or equal to %minValue.
  • INVALID_FIELD_MAX_VALUE - The %fieldName value of "%value" must be less than or equal to %maxValue.
  • INVALID_FIELD_VALUE - Invalid value of "%value" provided for the %fieldName field.
  • REQUIRED_FIELD - "%fieldName" is required. Enter and try again.

...