4

I'm new to Magento Rest Api and I was wondering where can I could mark a single product disabled/enabled with a rest call.

I've tried to change the visibility property via /V1/products/ but that does not change anything. enter image description here

Thanks in advance!

2
  • You can do up-vote (: Commented Oct 1, 2018 at 17:11
  • And what are the values for status? Its not 1 enabled and 2 disabled like in the eav. (0 default to enabled?) Is it 0 is disabled 1 is enabled? Commented Apr 1, 2020 at 0:56

1 Answer 1

2

you can achieve this using catalogProductRepositoryV1

method

PUT

url

http://magento.host/rest/V1/products/{sku}

Response Class (Status 200)

{
  "id": 0,
  "sku": "string",
  "name": "string",
  "attributeSetId": 0,
  "price": 0,
  "status": 0,
  "visibility": 0,
  "typeId": "string",
  "createdAt": "string",
  "updatedAt": "string",
  "weight": 0,
  "extensionAttributes": {
    "downloadableProductLinks": [
      {
        "id": 0,
        "title": "string",
        "sortOrder": 0,
        "isShareable": 0,
        "price": 0,
        "numberOfDownloads": 0,
        "linkType": "string",
        "linkFile": "string",
        "linkFileContent": {
          "fileData": "string",
          "name": "string",
          "extensionAttributes": {}
        },
        "linkUrl": "string",
        "sampleType": "string",
        "sampleFile": "string",
        "sampleFileContent": {
          "fileData": "string",
          "name": "string",
          "extensionAttributes": {}
        },
        "sampleUrl": "string",
        "extensionAttributes": {}
      }
    ],
    "downloadableProductSamples": [
      {
        "id": 0,
        "title": "string",
        "sortOrder": 0,
        "sampleType": "string",
        "sampleFile": "string",
        "sampleFileContent": {
          "fileData": "string",
          "name": "string",
          "extensionAttributes": {}
        },
        "sampleUrl": "string",
        "extensionAttributes": {}
      }
    ],
    "stockItem": {
      "itemId": 0,
      "productId": 0,
      "stockId": 0,
      "qty": 0,
      "isInStock": true,
      "isQtyDecimal": true,
      "showDefaultNotificationMessage": true,
      "useConfigMinQty": true,
      "minQty": 0,
      "useConfigMinSaleQty": 0,
      "minSaleQty": 0,
      "useConfigMaxSaleQty": true,
      "maxSaleQty": 0,
      "useConfigBackorders": true,
      "backorders": 0,
      "useConfigNotifyStockQty": true,
      "notifyStockQty": 0,
      "useConfigQtyIncrements": true,
      "qtyIncrements": 0,
      "useConfigEnableQtyInc": true,
      "enableQtyIncrements": true,
      "useConfigManageStock": true,
      "manageStock": true,
      "lowStockDate": "string",
      "isDecimalDivided": true,
      "stockStatusChangedAuto": 0,
      "extensionAttributes": {}
    },
    "giftcardAmounts": [
      {
        "websiteId": 0,
        "value": 0,
        "websiteValue": 0,
        "extensionAttributes": {}
      }
    ],
    "configurableProductOptions": [
      {
        "id": 0,
        "attributeId": "string",
        "label": "string",
        "position": 0,
        "isUseDefault": true,
        "values": [
          {
            "valueIndex": 0,
            "extensionAttributes": {}
          }
        ],
        "extensionAttributes": {},
        "productId": 0
      }
    ],
    "configurableProductLinks": [
      0
    ],
    "bundleProductOptions": [
      {
        "optionId": 0,
        "title": "string",
        "required": true,
        "type": "string",
        "position": 0,
        "sku": "string",
        "productLinks": [
          {
            "id": "string",
            "sku": "string",
            "optionId": 0,
            "qty": 0,
            "position": 0,
            "isDefault": true,
            "price": 0,
            "priceType": 0,
            "canChangeQuantity": 0,
            "extensionAttributes": {}
          }
        ],
        "extensionAttributes": {}
      }
    ]
  },
  "productLinks": [
    {
      "sku": "string",
      "linkType": "string",
      "linkedProductSku": "string",
      "linkedProductType": "string",
      "position": 0,
      "extensionAttributes": {
        "qty": 0
      }
    }
  ],
  "options": [
    {
      "productSku": "string",
      "optionId": 0,
      "title": "string",
      "type": "string",
      "sortOrder": 0,
      "isRequire": true,
      "price": 0,
      "priceType": "string",
      "sku": "string",
      "fileExtension": "string",
      "maxCharacters": 0,
      "imageSizeX": 0,
      "imageSizeY": 0,
      "values": [
        {
          "title": "string",
          "sortOrder": 0,
          "price": 0,
          "priceType": "string",
          "sku": "string",
          "optionTypeId": 0
        }
      ],
      "extensionAttributes": {}
    }
  ],
  "mediaGalleryEntries": [
    {
      "id": 0,
      "mediaType": "string",
      "label": "string",
      "position": 0,
      "disabled": true,
      "types": [
        "string"
      ],
      "file": "string",
      "content": {
        "base64EncodedData": "string",
        "type": "string",
        "name": "string"
      },
      "extensionAttributes": {
        "videoContent": {
          "mediaType": "string",
          "videoProvider": "string",
          "videoUrl": "string",
          "videoTitle": "string",
          "videoDescription": "string",
          "videoMetadata": "string"
        }
      }
    }
  ],
  "tierPrices": [
    {
      "customerGroupId": 0,
      "qty": 0,
      "value": 0,
      "extensionAttributes": {}
    }
  ],
  "customAttributes": [
    {
      "attributeCode": "string",
      "value": "string"
    }
  ]
}

you can change/update it using PUT method.

let me know if you have any query.

4
  • 1
    Thank you for your answer. However the question was more about what property do I need to change in order to disable/enable product? Commented Jul 27, 2018 at 10:27
  • yes you need to change value of status Commented Jul 27, 2018 at 10:29
  • sixth param after the price Commented Jul 27, 2018 at 10:30
  • Hello @gmarteinsson the above solution is working fine in magento 2.2.4 Commented Jul 27, 2018 at 13:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.