v1

latestOpenAPI 3.0.3raw.githubusercontent.com2024-10-2916802.4 MB
🛒 Ecommerce

Update product

The API enables an authenticated user with the role of ADMIN to update a product's information.

By passing the productId as a path variable, the API allows the user to modify the product's attributes such as name, description, price, stock, category (referenced by categoryId), mainImage (the primary image), and subImages (up to four additional images displayed in a carousel on the frontend).

All of these fields can be included in the request body as form data, and they are optional, meaning that only the provided fields will be updated.

patch/ecommerce/products/{productId}

Response

Update product

messagestring
statusCodenumber
successboolean

Example response

{
  "data": {
    "_id": "647c6059fe873dfa3c256fc3",
    "category": "647c406165391b736260db2b",
    "createdAt": "2023-06-04T09:58:49.324Z",
    "description": "Updated desc",
    "mainImage": {
      "_id": "647c65f480ce658300aead44",
      "localPath": "public/images/cover_image.png-168587416443763118173.png",
      "url": "http://localhost:8080/images/cover_image.png-168587416443763118173.png"
    },
    "name": "Updated",
    "owner": "647c5d68a1ce9c25a8033233",
    "price": 1234,
    "stock": 20,
    "subImages": [
      {
        "_id": "647c624209e864c63841e348",
        "localPath": "public/images/splash-1splash.png-1685873218943.png",
        "url": "http://localhost:8080/images/splash-1splash.png-1685873218943.png"
      },
      {
        "_id": "647c624209e864c63841e349",
        "localPath": "public/images/Rectangle-1splash.png-1685873218945.png",
        "url": "http://localhost:8080/images/Rectangle-1splash.png-1685873218945.png"
      },
      {
        "_id": "647c624709e864c63841e354",
        "localPath": "public/images/splash-1splash.png-1685873223567.png",
        "url": "http://localhost:8080/images/splash-1splash.png-1685873223567.png"
      },
      {
        "_id": "647c624709e864c63841e355",
        "localPath": "public/images/Rectangle-1splash.png-1685873223568.png",
        "url": "http://localhost:8080/images/Rectangle-1splash.png-1685873223568.png"
      }
    ],
    "updatedAt": "2023-06-04T10:22:44.459Z"
  },
  "message": "Product updated successfully",
  "statusCode": 200,
  "success": true
}