Управление запасами после заказа, созданного через rest API в версии Magento 2.x (без корзины) - PullRequest
0 голосов
/ 01 апреля 2019

Я создал Magento rest API для сторонних интеграций, и я использовал пару API для перечисления продуктов, получения сведений о продукте и созданного заказа.

Я использовал [PUT] - / V1 / orders /создать - этот API для создания заказа и заказ был успешно создан в админ-панели Magento.

Мой вопрос: всякий раз, когда мы создаем заказ, это не влияет на количество продукта (управление запасами).

API - [PUT] - / V1 / orders / create

Payload:

{
  "entity": {
    "base_currency_code": "USD",
    "base_discount_amount": 0,
    "base_grand_total": 64,
    "base_shipping_amount": 5,
    "base_shipping_incl_tax": 5,
    "base_shipping_tax_amount": 0,
    "base_shipping_discount_amount": 0,
    "base_subtotal": 59,
    "base_subtotal_incl_tax": 59,
    "base_total_due": 0,
    "base_total_paid" : 64,
    "base_to_global_rate": 0,
    "base_to_order_rate": 0,
    "discount_tax_compensation_amount": 0,
    "base_discount_tax_compensation_amount": 0,
    "shipping_discount_tax_compensation_amount": 0,
    "customer_is_guest": 1,
    "customer_email": "deeban@vuedata.com",
    "customer_firstname": "Deeban",
    "customer_lastname": "Babu",
    "customer_note_notify": 1,
    "discount_amount": 0,
    "email_sent": 1,
    "global_currency_code": "USD",
    "grand_total": 64,
    "order_currency_code": "USD",
    "shipping_amount": 5,
    "shipping_tax_amount": 0,
    "shipping_description": "Flat Rate - Fixed",
    "shipping_discount_amount": 0,
    "shipping_incl_tax": 5,
    "state": "complete",
    "status": "complete",
    "store_currency_code": "USD",
    "store_to_base_rate": 0,
    "store_to_order_rate": 0,
    "store_id": 1,
    "subtotal": 59,
    "subtotal_incl_tax": 59,
    "total_due": 0,
    "total_paid" : 64,
    "total_item_count": 1,
    "total_qty_ordered": 1,
    "tax_amount": 0,
    "weight": 1,
    "items": [{
      "base_original_price": 59,
      "base_price": 59,
      "base_price_incl_tax": 59,
      "base_row_total": 59,
      "base_row_total_incl_tax": 59,
      "name": "Fusion Backpack",
      "original_price": 59,
      "price": 59,
      "price_incl_tax": 59,
      "product_id": 6,
      "product_type": "simple",
      "qty_ordered": 1,
      "row_total": 59,
      "row_total_incl_tax": 59,
      "sku": "24-MB02",
      "store_id": 1,
      "weight": 1
    }],
    "billing_address": {
      "address_type": "billing",
      "city": "Chennai ",
      "company": "",
      "country_id": "IN",
      "customer_address_id": 0,
      "email": "deeban@vuedata.com",
      "firstname": "deeban",
      "lastname": "babu",
      "postcode": "600041",
      "region": "TN",
      "street": ["chennai"],
      "telephone": "9043202246"
    },
    "payment": {
      "amount_ordered": 64,
      "amount_paid":64,
      "base_amount_ordered": 64,
      "base_amount_paid" : 64,
      "base_shipping_amount": 5,
      "method": "checkmo",
      "shipping_amount": 5
    },
    "status_histories": [{
      "comment" : "new order",
      "status": "complete"
    }],
    "extension_attributes": {
      "shipping_assignments": [{
        "shipping": {
          "address": {
            "address_type": "shipping",
            "city": "Chennai",
            "company": "",
            "country_id": "IN",
            "customer_address_id": 0,
            "email": "deeban@vuedata.com",
            "firstname": "deeban",
            "lastname": "babu",
            "postcode": "600041",
            "region": "TN",
            "street": ["chennai"],
            "telephone": "9043202246"
          },
          "method": "flatrate_flatrate",
          "total": {
            "base_shipping_amount": 5,
            "base_shipping_incl_tax": 5,
            "shipping_amount": 5,
            "shipping_incl_tax": 5
          },
          "extension_attributes": []
        },

        "extension_attributes": []
      }],
      "applied_taxes": [],
      "item_applied_taxes": [],
      "converting_from_quote": false
    }
  }
}

Response:

{
    "base_currency_code": "USD",
    "base_discount_amount": 0,
    "base_grand_total": 64,
    "base_discount_tax_compensation_amount": 0,
    "base_shipping_amount": 5,
    "base_shipping_discount_amount": 0,
    "base_shipping_incl_tax": 5,
    "base_shipping_tax_amount": 0,
    "base_subtotal": 59,
    "base_subtotal_incl_tax": 59,
    "base_total_due": 0,
    "base_total_paid": 64,
    "base_to_global_rate": 0,
    "base_to_order_rate": 0,
    "billing_address_id": 34,
    "created_at": "2019-04-01 09:23:38",
    "customer_email": "deeban@vuedata.com",
    "customer_firstname": "Deeban",
    "customer_is_guest": 1,
    "customer_lastname": "Babu",
    "customer_note_notify": 1,
    "discount_amount": 0,
    "email_sent": 1,
    "entity_id": 22,
    "global_currency_code": "USD",
    "grand_total": 64,
    "discount_tax_compensation_amount": 0,
    "increment_id": "000000030",
    "order_currency_code": "USD",
    "protect_code": "855f88ee22e98a9441df11594c801f7d",
    "shipping_amount": 5,
    "shipping_description": "Flat Rate - Fixed",
    "shipping_discount_amount": 0,
    "shipping_discount_tax_compensation_amount": 0,
    "shipping_incl_tax": 5,
    "shipping_tax_amount": 0,
    "state": "complete",
    "status": "complete",
    "store_currency_code": "USD",
    "store_id": 1,
    "store_name": "Main Website\nMain Website Store\nDefault Store View",
    "store_to_base_rate": 0,
    "store_to_order_rate": 0,
    "subtotal": 59,
    "subtotal_incl_tax": 59,
    "tax_amount": 0,
    "total_due": 0,
    "total_item_count": 1,
    "total_paid": 64,
    "total_qty_ordered": 1,
    "updated_at": "2019-04-01 09:23:38",
    "weight": 1,
    "items": [
        {
            "base_original_price": 59,
            "base_price": 59,
            "base_price_incl_tax": 59,
            "base_row_total": 59,
            "base_row_total_incl_tax": 59,
            "created_at": "2019-04-01 09:23:38",
            "item_id": 20,
            "name": "Fusion Backpack",
            "order_id": 22,
            "original_price": 59,
            "price": 59,
            "price_incl_tax": 59,
            "product_id": 6,
            "product_type": "simple",
            "qty_ordered": 1,
            "row_total": 59,
            "row_total_incl_tax": 59,
            "sku": "24-MB02",
            "store_id": 1,
            "updated_at": "2019-04-01 09:23:38",
            "weight": 1
        }
    ],
    "billing_address": {
        "address_type": "billing",
        "city": "Chennai ",
        "company": "",
        "country_id": "IN",
        "customer_address_id": 0,
        "email": "deeban@vuedata.com",
        "entity_id": 34,
        "firstname": "deeban",
        "lastname": "babu",
        "parent_id": 22,
        "postcode": "600041",
        "region": "TN",
        "region_code": "TN",
        "street": [
            "chennai"
        ],
        "telephone": "9043202246"
    },
    "payment": {
        "account_status": null,
        "additional_information": [],
        "amount_ordered": 64,
        "amount_paid": 64,
        "base_amount_ordered": 64,
        "base_amount_paid": 64,
        "base_shipping_amount": 5,
        "cc_last4": null,
        "entity_id": 20,
        "method": "checkmo",
        "parent_id": 22,
        "shipping_amount": 5
    },
    "status_histories": [
        {
            "comment": "new order",
            "entity_id": 5,
            "is_customer_notified": null,
            "is_visible_on_front": null,
            "parent_id": 22,
            "status": "complete"
        }
    ],
    "extension_attributes": {
        "shipping_assignments": [
            {
                "shipping": {
                    "address": {
                        "address_type": "shipping",
                        "city": "Chennai",
                        "company": "",
                        "country_id": "IN",
                        "customer_address_id": 0,
                        "email": "deeban@vuedata.com",
                        "entity_id": 35,
                        "firstname": "deeban",
                        "lastname": "babu",
                        "parent_id": 22,
                        "postcode": "600041",
                        "region": "TN",
                        "region_code": "TN",
                        "street": [
                            "chennai"
                        ],
                        "telephone": "9043202246"
                    },
                    "method": "flatrate_flatrate",
                    "total": {
                        "base_shipping_amount": 5,
                        "base_shipping_incl_tax": 5,
                        "shipping_amount": 5,
                        "shipping_incl_tax": 5
                    }
                },
                "items": null
            }
        ],
        "applied_taxes": [],
        "item_applied_taxes": [],
        "converting_from_quote": false
    }
}
...