Magento – Magento 2 API, catalog price rule is not applied

magento2

The catalog price rule is working in frontend. But when we get the product from REST API, we are getting the original price only.

Example:
Product price is 34, we were created catalog rule with 10% for all products, in frontend we are getting both prices 30.26 and 34. But from api, we are getting only 34.

Please help.

API EndPoint:

http://localhost/magento/rest/default/V1/products/24-MB01

Partial Response:
{
  "id": 1,
  "sku": "24-MB01",
  "name": "Joust Duffle Bag",
  "attribute_set_id": 15,
  "price": 34,
  "status": 1,
  "visibility": 4,
  "type_id": "simple",
  "created_at": "2017-01-10 07:50:47",
  "updated_at": "2017-01-10 07:50:47",
  "extension_attributes": [],
  "product_links": [],
  "options": [],
}

Best Answer

Special Price is a custom attributes so you will get its details response in Custom Attributes section.

So follow below steps :

  1. Your Api end point should be - http://yourwebsitelink/index.php/rest/default/V1/products/24-MB01/
  2. Pass Authorization Bearer your_access_token in the header
  3. You will get the full response wit details of that product :
  4. So over there at last you will find option "custom_attributes" like below :
"tier_prices": [],
  "custom_attributes": [
    {
      "attribute_code": "description",
      "value": "<p>The sporty Joust Duffle Bag can't be beat"
    },
    {
      "attribute_code": "special_price",
      "value": "30.0000"
    },
    {
      "attribute_code": "special_from_date",
      "value": "2017-02-07 00:00:00"
    },
    {
      "attribute_code": "special_to_date",
      "value": "2017-02-28 00:00:00"
    },
    {
      "attribute_code": "cost",
      "value": "30.0000"
    },
    {
      "attribute_code": "image",
      "value": "/m/b/mb01-blue-0.jpg"
    },
    {
      "attribute_code": "small_image",
      "value": "/m/b/mb01-blue-0.jpg"
    },
    {
      "attribute_code": "thumbnail",
      "value": "/m/b/mb01-blue-0.jpg"
    },
    {
      "attribute_code": "color",
      "value": "49"
    },
    {
      "attribute_code": "news_from_date",
      "value": "2017-02-15 00:00:00"
    },
    {
      "attribute_code": "custom_design_from",
      "value": "2017-02-15 00:00:00"
    },
    {
      "attribute_code": "category_ids",
      "value": [
        "3",
        "4"
      ]
    },
  1. From there you will get attribute_code = special_price and its value