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!

  • You can do up-vote (: – Aditya Shah Oct 1 '18 at 17:11
1

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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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