Create a Custom REST API for Bulk product update in Magento 2.

Native Magento comes with a lot of REST APIs for different Entities like Product, Order, Customer, and other APIs.

I want to give a demo for updating bulk products using rest API in Magento 2.

By Default Native Magento doesn’t provide Bulk Product Update API. You need to call REST API to iterate over a loop. At a time you can update only a single product. Continue reading “Create a Custom REST API for Bulk product update in Magento 2.”

How to update order status using Rest API Magento 2?

We can update Order status using REST api in Magento 2 by just simple payload. For Create Order, Create order using rest api in Magento 2
We required the order_id, order status, and order_incrementid for update order status.
Request:{YOUR_URL}/rest/V1/orders

Type: POST

Body:

POST
{
  "entity":{
    "entity_id":10,
    "status":"processing",
    "increment_id":"000000010"
  }
}

Response:

{
    "base_grand_total": null,
    "base_total_due": 0,
    "billing_address_id": 204,
    "created_at": "2018-09-16 18:12:42",
    "customer_email": null,
    "entity_id": 10,
    "grand_total": null,
    "increment_id": "000000010",
    "protect_code": "352f3f47cd42aa50f0e7e328ffd53040",
    "status": "processing",
    "total_due": 0,
    "updated_at": "2018-09-16 18:44:57",
    "items": [
        {
            "amount_refunded": 0,
            "base_amount_refunded": 0,
            "base_cost": 0,
            "base_discount_amount": 4.5,
            "base_discount_invoiced": 0,
            "base_original_price": 45,
            "base_price": 45,
            "base_price_incl_tax": 45,
            "base_row_invoiced": 0,
            "base_row_total": 45,
            "base_tax_amount": 0,
            "base_tax_invoiced": 0,
            "created_at": "2018-09-16 18:12:42",
            "discount_amount": 4.5,
            "discount_invoiced": 0,
            "discount_percent": 10,
            "free_shipping": 0,
            "is_virtual": 0,
            "item_id": 124,
            "name": "Push It Messenger Bag",
            "no_discount": 0,
            "order_id": 103,
            "original_price": 45,
            "price": 45,
            "price_incl_tax": 45,
            "product_id": 14,
            "product_type": "simple",
            "qty_backordered": 0,
            "qty_canceled": 0,
            "qty_invoiced": 0,
            "qty_ordered": 1,
            "qty_refunded": 0,
            "qty_returned": 0,
            "qty_shipped": 0,
            "row_invoiced": 0,
            "row_total": 45,
            "row_total_incl_tax": 45,
            "row_weight": 0,
            "sku": "24-WB04",
            "store_id": 1,
            "tax_amount": 0,
            "tax_invoiced": 0,
            "tax_percent": 0,
            "updated_at": "2018-09-16 18:12:42",
            "weight": 0
        }
    ],
    "billing_address": {
        "address_type": "billing",
        "city": "Ahmedabad",
        "company": "Rbj",
        "country_id": "US",
        "email": "rakesh@rakeshjesadiya.com",
        "entity_id": 204,
        "firstname": "rakesh",
        "lastname": "jesadiya",
        "parent_id": 103,
        "postcode": "30332",
        "region": "Georgia",
        "region_code": "GA",
        "region_id": 19,
        "street": [
            "Street 1",
            "Street 2"
        ],
        "telephone": "123456"
    },
    "payment": {
        "account_status": null,
        "additional_information": [
            ""
        ],
        "cc_last4": null,
        "entity_id": 103,
        "method": "cashondelivery",
        "parent_id": 103
    },
    "status_histories": []
}

 

 

How to create Invoice using Rest API Magento 2?

Magento 2 is robust,scalable and multi feature enable eCommerce platform. You can create Invoice of an Order Using an third party platform to Magento 2 by API request.

For Create order, Create order using Rest API Magento 2

For Create Shipment Using API, Create Shipment using Rest API Magento 2
Using below payload you can create Shipment of an order using any third party platform to Magento 2. you Just need to pass below payload in your request with POST data.

Request:
{YOUR_URL}/rest/V1/order/{order_id}/invoice

Type: POST

Body:

{
  "capture": true,
  "items": [
    {
      "extension_attributes": {},
      "order_item_id": 82,
      "qty": 1
    }
  ],
  "notify": true,
  "appendComment": true,
  "comment": {
    "extension_attributes": {},
    "comment": "Order Invoice generate",
    "is_visible_on_front": 0
  },
  "arguments": {
    "extension_attributes": {}
  }
}

Pass order_item_id is your order item’s id don’t pass order id in order_item_id field. Pass order_id in reqeuest Url. You can create multiple request using pass multi array in items array.

Response:
10 (new Invoice id)