Skip to main content
Bumped by Community user
Tweeted twitter.com/StackMagento/status/833971865391603712
added 748 characters in body; edited tags; edited title
Source Link
Khoa TruongDinh
  • 32.3k
  • 11
  • 90
  • 156

Magento 2 Update a product name using Rest API

I'm using POSTMAN, ex: Request a PUT on http://localhost/mystore/rest/V1/products/24-MB04:

{

"product" : { "name" : "TESTE PRODUCT NAME", "weight" : 200, "custom_attributes": [ { "attribute_code": "MARCA", "value"http://localhost/mystore/rest/V1/products/24-MB04: "TEST" } ]

} }

{

  "product" : {
        "name" : "TESTE PRODUCT NAME",
        "weight" : 200,
        "custom_attributes": [
        {
          "attribute_code": "MARCA",
          "value": "TEST"
        }
      ]
  
  }
}

{ "id": 2, "sku": "24-MB04", "name": "TESTE PRODUCT NAME", "attribute_set_id": 15, "price": 32, "status": 1, "visibility": 4, "type_id": "simple", "created_at": "2016-06-26 15:22:24", "updated_at": "2016-06-26 15:22:24", "weight": 200, "extension_attributes": { "stock_item": { "item_id": 2, "product_id": 2, "stock_id": 1, "qty": 100, "is_in_stock": true, "is_qty_decimal": false, "show_default_notification_message": false, "use_config_min_qty": true, "min_qty": 0, "use_config_min_sale_qty": 1, "min_sale_qty": 1, "use_config_max_sale_qty": true, "max_sale_qty": 10000, "use_config_backorders": true, "backorders": 0, "use_config_notify_stock_qty": true, "notify_stock_qty": 1, "use_config_qty_increments": true, "qty_increments": 0, "use_config_enable_qty_inc": true, "enable_qty_increments": false, "use_config_manage_stock": true, "manage_stock": true, "low_stock_date": null, "is_decimal_divided": false, "stock_status_changed_auto": 0 } }, "product_links": [], "options": [], "media_gallery_entries": [ { "id": 2, "media_type": "image", "label": "Image", "position": 1, "disabled": false, "types": [ "image", "small_image", "thumbnail" ], "file": "/m/b/mb04-black-0.jpg" }, { "id": 3, "media_type": "image", "label": "Image", "position": 2, "disabled": false, "types": [], "file": "/m/b/mb04-black-0_alt1.jpg" } ], "tier_prices": [], "custom_attributes": [ { "attribute_code": "description", "value": "

Convenience is next to nothing when your day is crammed with action. So whether you're heading to class, gym, or the unbeaten path, make sure you've got your Strive Shoulder Pack stuffed with all your essentials, and extras as well.

\n
    \n
  • Zippered main compartment.
  • \n
  • Front zippered pocket.
  • \n
  • Side mesh pocket.
  • \n
  • Cell phone pocket on strap.
  • \n
  • Adjustable shoulder strap and top carry handle.
  • \n
"},{"attribute_code": "special_price","value": "32.0000"},{"attribute_code": "special_from_date","value": "2016-06-26 15:22:24"},{"attribute_code": "image","value": "/m/b/mb04-black-0.jpg"},{"attribute_code": "small_image","value": "/m/b/mb04-black-0.jpg"},{"attribute_code": "thumbnail","value": "/m/b/mb04-black-0.jpg"},{"attribute_code": "color","value": "49"},{"attribute_code": "news_from_date","value": "2016-06-26 15:22:24"},{"attribute_code": "custom_design_from","value": "2016-06-26 15:22:24"},{"attribute_code": "category_ids","value": ["3","7","4"]},{"attribute_code": "options_container","value": "container2"},{"attribute_code": "required_options","value": "0"},{"attribute_code": "has_options","value": "0"},{"attribute_code": "url_key","value": "strive-shoulder-pack"},{"attribute_code": "tax_class_id","value": "2"},{"attribute_code": "activity","value": "11,21,23,18"},{"attribute_code": "style_bags","value": "27,29,30"},{"attribute_code": "material","value": "32,33,36,38"},{"attribute_code": "strap_bags","value": "61,62,65,66,67"},{"attribute_code": "features_bags","value": "72,74,75,78"},{"attribute_code": "size","value": "91"},{"attribute_code": "erin_recommends","value": "1"},{"attribute_code": "sale","value": "1"},{"attribute_code": "marca","value": "TEST"}]}

{
  "id": 2,
  "sku": "24-MB04",
  "name": "TESTE PRODUCT NAME",
  "attribute_set_id": 15,
  "price": 32,
  "status": 1,
  "visibility": 4,
  "type_id": "simple",
  "created_at": "2016-06-26 15:22:24",
  "updated_at": "2016-06-26 15:22:24",
  "weight": 200,
  "extension_attributes": {
    "stock_item": {
      "item_id": 2,
      "product_id": 2,
      "stock_id": 1,
      "qty": 100,
      "is_in_stock": true,
      "is_qty_decimal": false,
      "show_default_notification_message": false,
      "use_config_min_qty": true,
      "min_qty": 0,
      "use_config_min_sale_qty": 1,
      "min_sale_qty": 1,
      "use_config_max_sale_qty": true,
      "max_sale_qty": 10000,
      "use_config_backorders": true,
      "backorders": 0,
      "use_config_notify_stock_qty": true,
      "notify_stock_qty": 1,
      "use_config_qty_increments": true,
      "qty_increments": 0,
      "use_config_enable_qty_inc": true,
      "enable_qty_increments": false,
      "use_config_manage_stock": true,
      "manage_stock": true,
      "low_stock_date": null,
      "is_decimal_divided": false,
      "stock_status_changed_auto": 0
    }
  },
  "product_links": [],
  "options": [],
  "media_gallery_entries": [
    {
      "id": 2,
      "media_type": "image",
      "label": "Image",
      "position": 1,
      "disabled": false,
      "types": [
        "image",
        "small_image",
        "thumbnail"
      ],
      "file": "/m/b/mb04-black-0.jpg"
    },
    {
      "id": 3,
      "media_type": "image",
      "label": "Image",
      "position": 2,
      "disabled": false,
      "types": [],
      "file": "/m/b/mb04-black-0_alt1.jpg"
    }
  ],
  "tier_prices": [],
  "custom_attributes": [
    {
      "attribute_code": "description",
      "value": "<p>Convenience is next to nothing when your day is crammed with action. So whether you're heading to class, gym, or the unbeaten path, make sure you've got your Strive Shoulder Pack stuffed with all your essentials, and extras as well.</p>\n<ul>\n<li>Zippered main compartment.</li>\n<li>Front zippered pocket.</li>\n<li>Side mesh pocket.</li>\n<li>Cell phone pocket on strap.</li>\n<li>Adjustable shoulder strap and top carry handle.</li>\n</ul>"
    },
    {
      "attribute_code": "special_price",
      "value": "32.0000"
    },
    {
      "attribute_code": "special_from_date",
      "value": "2016-06-26 15:22:24"
    },
    {
      "attribute_code": "image",
      "value": "/m/b/mb04-black-0.jpg"
    },
    {
      "attribute_code": "small_image",
      "value": "/m/b/mb04-black-0.jpg"
    },
    {
      "attribute_code": "thumbnail",
      "value": "/m/b/mb04-black-0.jpg"
    },
    {
      "attribute_code": "color",
      "value": "49"
    },
    {
      "attribute_code": "news_from_date",
      "value": "2016-06-26 15:22:24"
    },
    {
      "attribute_code": "custom_design_from",
      "value": "2016-06-26 15:22:24"
    },
    {
      "attribute_code": "category_ids",
      "value": [
        "3",
        "7",
        "4"
      ]
    },
    {
      "attribute_code": "options_container",
      "value": "container2"
    },
    {
      "attribute_code": "required_options",
      "value": "0"
    },
    {
      "attribute_code": "has_options",
      "value": "0"
    },
    {
      "attribute_code": "url_key",
      "value": "strive-shoulder-pack"
    },
    {
      "attribute_code": "tax_class_id",
      "value": "2"
    },
    {
      "attribute_code": "activity",
      "value": "11,21,23,18"
    },
    {
      "attribute_code": "style_bags",
      "value": "27,29,30"
    },
    {
      "attribute_code": "material",
      "value": "32,33,36,38"
    },
    {
      "attribute_code": "strap_bags",
      "value": "61,62,65,66,67"
    },
    {
      "attribute_code": "features_bags",
      "value": "72,74,75,78"
    },
    {
      "attribute_code": "size",
      "value": "91"
    },
    {
      "attribute_code": "erin_recommends",
      "value": "1"
    },
    {
      "attribute_code": "sale",
      "value": "1"
    },
    {
      "attribute_code": "marca",
      "value": "TEST"
    }
  ]
}

Update a product name using Rest API

I'm using POSTMAN, ex: Request a PUT on http://localhost/mystore/rest/V1/products/24-MB04:

{

"product" : { "name" : "TESTE PRODUCT NAME", "weight" : 200, "custom_attributes": [ { "attribute_code": "MARCA", "value": "TEST" } ]

} }

{ "id": 2, "sku": "24-MB04", "name": "TESTE PRODUCT NAME", "attribute_set_id": 15, "price": 32, "status": 1, "visibility": 4, "type_id": "simple", "created_at": "2016-06-26 15:22:24", "updated_at": "2016-06-26 15:22:24", "weight": 200, "extension_attributes": { "stock_item": { "item_id": 2, "product_id": 2, "stock_id": 1, "qty": 100, "is_in_stock": true, "is_qty_decimal": false, "show_default_notification_message": false, "use_config_min_qty": true, "min_qty": 0, "use_config_min_sale_qty": 1, "min_sale_qty": 1, "use_config_max_sale_qty": true, "max_sale_qty": 10000, "use_config_backorders": true, "backorders": 0, "use_config_notify_stock_qty": true, "notify_stock_qty": 1, "use_config_qty_increments": true, "qty_increments": 0, "use_config_enable_qty_inc": true, "enable_qty_increments": false, "use_config_manage_stock": true, "manage_stock": true, "low_stock_date": null, "is_decimal_divided": false, "stock_status_changed_auto": 0 } }, "product_links": [], "options": [], "media_gallery_entries": [ { "id": 2, "media_type": "image", "label": "Image", "position": 1, "disabled": false, "types": [ "image", "small_image", "thumbnail" ], "file": "/m/b/mb04-black-0.jpg" }, { "id": 3, "media_type": "image", "label": "Image", "position": 2, "disabled": false, "types": [], "file": "/m/b/mb04-black-0_alt1.jpg" } ], "tier_prices": [], "custom_attributes": [ { "attribute_code": "description", "value": "

Convenience is next to nothing when your day is crammed with action. So whether you're heading to class, gym, or the unbeaten path, make sure you've got your Strive Shoulder Pack stuffed with all your essentials, and extras as well.

\n
    \n
  • Zippered main compartment.
  • \n
  • Front zippered pocket.
  • \n
  • Side mesh pocket.
  • \n
  • Cell phone pocket on strap.
  • \n
  • Adjustable shoulder strap and top carry handle.
  • \n
"},{"attribute_code": "special_price","value": "32.0000"},{"attribute_code": "special_from_date","value": "2016-06-26 15:22:24"},{"attribute_code": "image","value": "/m/b/mb04-black-0.jpg"},{"attribute_code": "small_image","value": "/m/b/mb04-black-0.jpg"},{"attribute_code": "thumbnail","value": "/m/b/mb04-black-0.jpg"},{"attribute_code": "color","value": "49"},{"attribute_code": "news_from_date","value": "2016-06-26 15:22:24"},{"attribute_code": "custom_design_from","value": "2016-06-26 15:22:24"},{"attribute_code": "category_ids","value": ["3","7","4"]},{"attribute_code": "options_container","value": "container2"},{"attribute_code": "required_options","value": "0"},{"attribute_code": "has_options","value": "0"},{"attribute_code": "url_key","value": "strive-shoulder-pack"},{"attribute_code": "tax_class_id","value": "2"},{"attribute_code": "activity","value": "11,21,23,18"},{"attribute_code": "style_bags","value": "27,29,30"},{"attribute_code": "material","value": "32,33,36,38"},{"attribute_code": "strap_bags","value": "61,62,65,66,67"},{"attribute_code": "features_bags","value": "72,74,75,78"},{"attribute_code": "size","value": "91"},{"attribute_code": "erin_recommends","value": "1"},{"attribute_code": "sale","value": "1"},{"attribute_code": "marca","value": "TEST"}]}

Magento 2 Update a product name using Rest API

I'm using POSTMAN, ex: Request a PUT on http://localhost/mystore/rest/V1/products/24-MB04:

{

  "product" : {
        "name" : "TESTE PRODUCT NAME",
        "weight" : 200,
        "custom_attributes": [
        {
          "attribute_code": "MARCA",
          "value": "TEST"
        }
      ]
  
  }
}
{
  "id": 2,
  "sku": "24-MB04",
  "name": "TESTE PRODUCT NAME",
  "attribute_set_id": 15,
  "price": 32,
  "status": 1,
  "visibility": 4,
  "type_id": "simple",
  "created_at": "2016-06-26 15:22:24",
  "updated_at": "2016-06-26 15:22:24",
  "weight": 200,
  "extension_attributes": {
    "stock_item": {
      "item_id": 2,
      "product_id": 2,
      "stock_id": 1,
      "qty": 100,
      "is_in_stock": true,
      "is_qty_decimal": false,
      "show_default_notification_message": false,
      "use_config_min_qty": true,
      "min_qty": 0,
      "use_config_min_sale_qty": 1,
      "min_sale_qty": 1,
      "use_config_max_sale_qty": true,
      "max_sale_qty": 10000,
      "use_config_backorders": true,
      "backorders": 0,
      "use_config_notify_stock_qty": true,
      "notify_stock_qty": 1,
      "use_config_qty_increments": true,
      "qty_increments": 0,
      "use_config_enable_qty_inc": true,
      "enable_qty_increments": false,
      "use_config_manage_stock": true,
      "manage_stock": true,
      "low_stock_date": null,
      "is_decimal_divided": false,
      "stock_status_changed_auto": 0
    }
  },
  "product_links": [],
  "options": [],
  "media_gallery_entries": [
    {
      "id": 2,
      "media_type": "image",
      "label": "Image",
      "position": 1,
      "disabled": false,
      "types": [
        "image",
        "small_image",
        "thumbnail"
      ],
      "file": "/m/b/mb04-black-0.jpg"
    },
    {
      "id": 3,
      "media_type": "image",
      "label": "Image",
      "position": 2,
      "disabled": false,
      "types": [],
      "file": "/m/b/mb04-black-0_alt1.jpg"
    }
  ],
  "tier_prices": [],
  "custom_attributes": [
    {
      "attribute_code": "description",
      "value": "<p>Convenience is next to nothing when your day is crammed with action. So whether you're heading to class, gym, or the unbeaten path, make sure you've got your Strive Shoulder Pack stuffed with all your essentials, and extras as well.</p>\n<ul>\n<li>Zippered main compartment.</li>\n<li>Front zippered pocket.</li>\n<li>Side mesh pocket.</li>\n<li>Cell phone pocket on strap.</li>\n<li>Adjustable shoulder strap and top carry handle.</li>\n</ul>"
    },
    {
      "attribute_code": "special_price",
      "value": "32.0000"
    },
    {
      "attribute_code": "special_from_date",
      "value": "2016-06-26 15:22:24"
    },
    {
      "attribute_code": "image",
      "value": "/m/b/mb04-black-0.jpg"
    },
    {
      "attribute_code": "small_image",
      "value": "/m/b/mb04-black-0.jpg"
    },
    {
      "attribute_code": "thumbnail",
      "value": "/m/b/mb04-black-0.jpg"
    },
    {
      "attribute_code": "color",
      "value": "49"
    },
    {
      "attribute_code": "news_from_date",
      "value": "2016-06-26 15:22:24"
    },
    {
      "attribute_code": "custom_design_from",
      "value": "2016-06-26 15:22:24"
    },
    {
      "attribute_code": "category_ids",
      "value": [
        "3",
        "7",
        "4"
      ]
    },
    {
      "attribute_code": "options_container",
      "value": "container2"
    },
    {
      "attribute_code": "required_options",
      "value": "0"
    },
    {
      "attribute_code": "has_options",
      "value": "0"
    },
    {
      "attribute_code": "url_key",
      "value": "strive-shoulder-pack"
    },
    {
      "attribute_code": "tax_class_id",
      "value": "2"
    },
    {
      "attribute_code": "activity",
      "value": "11,21,23,18"
    },
    {
      "attribute_code": "style_bags",
      "value": "27,29,30"
    },
    {
      "attribute_code": "material",
      "value": "32,33,36,38"
    },
    {
      "attribute_code": "strap_bags",
      "value": "61,62,65,66,67"
    },
    {
      "attribute_code": "features_bags",
      "value": "72,74,75,78"
    },
    {
      "attribute_code": "size",
      "value": "91"
    },
    {
      "attribute_code": "erin_recommends",
      "value": "1"
    },
    {
      "attribute_code": "sale",
      "value": "1"
    },
    {
      "attribute_code": "marca",
      "value": "TEST"
    }
  ]
}
Source Link

Update a product name using Rest API

I got to update weight, qty, price and others field, but when I update the product name, on catalog list (admin) the product change the name, but when I enter on edit view, the product continue with the last name and on store search, the name continue the last too. But on API rest the name is updated.

I'm using POSTMAN, ex: Request a PUT on http://localhost/mystore/rest/V1/products/24-MB04:

{

"product" : { "name" : "TESTE PRODUCT NAME", "weight" : 200, "custom_attributes": [ { "attribute_code": "MARCA", "value": "TEST" } ]

} }

The response was

{ "id": 2, "sku": "24-MB04", "name": "TESTE PRODUCT NAME", "attribute_set_id": 15, "price": 32, "status": 1, "visibility": 4, "type_id": "simple", "created_at": "2016-06-26 15:22:24", "updated_at": "2016-06-26 15:22:24", "weight": 200, "extension_attributes": { "stock_item": { "item_id": 2, "product_id": 2, "stock_id": 1, "qty": 100, "is_in_stock": true, "is_qty_decimal": false, "show_default_notification_message": false, "use_config_min_qty": true, "min_qty": 0, "use_config_min_sale_qty": 1, "min_sale_qty": 1, "use_config_max_sale_qty": true, "max_sale_qty": 10000, "use_config_backorders": true, "backorders": 0, "use_config_notify_stock_qty": true, "notify_stock_qty": 1, "use_config_qty_increments": true, "qty_increments": 0, "use_config_enable_qty_inc": true, "enable_qty_increments": false, "use_config_manage_stock": true, "manage_stock": true, "low_stock_date": null, "is_decimal_divided": false, "stock_status_changed_auto": 0 } }, "product_links": [], "options": [], "media_gallery_entries": [ { "id": 2, "media_type": "image", "label": "Image", "position": 1, "disabled": false, "types": [ "image", "small_image", "thumbnail" ], "file": "/m/b/mb04-black-0.jpg" }, { "id": 3, "media_type": "image", "label": "Image", "position": 2, "disabled": false, "types": [], "file": "/m/b/mb04-black-0_alt1.jpg" } ], "tier_prices": [], "custom_attributes": [ { "attribute_code": "description", "value": "

Convenience is next to nothing when your day is crammed with action. So whether you're heading to class, gym, or the unbeaten path, make sure you've got your Strive Shoulder Pack stuffed with all your essentials, and extras as well.

\n
    \n
  • Zippered main compartment.
  • \n
  • Front zippered pocket.
  • \n
  • Side mesh pocket.
  • \n
  • Cell phone pocket on strap.
  • \n
  • Adjustable shoulder strap and top carry handle.
  • \n
" }, { "attribute_code": "special_price", "value": "32.0000" }, { "attribute_code": "special_from_date", "value": "2016-06-26 15:22:24" }, { "attribute_code": "image", "value": "/m/b/mb04-black-0.jpg" }, { "attribute_code": "small_image", "value": "/m/b/mb04-black-0.jpg" }, { "attribute_code": "thumbnail", "value": "/m/b/mb04-black-0.jpg" }, { "attribute_code": "color", "value": "49" }, { "attribute_code": "news_from_date", "value": "2016-06-26 15:22:24" }, { "attribute_code": "custom_design_from", "value": "2016-06-26 15:22:24" }, { "attribute_code": "category_ids", "value": [ "3", "7", "4" ] }, { "attribute_code": "options_container", "value": "container2" }, { "attribute_code": "required_options", "value": "0" }, { "attribute_code": "has_options", "value": "0" }, { "attribute_code": "url_key", "value": "strive-shoulder-pack" }, { "attribute_code": "tax_class_id", "value": "2" }, { "attribute_code": "activity", "value": "11,21,23,18" }, { "attribute_code": "style_bags", "value": "27,29,30" }, { "attribute_code": "material", "value": "32,33,36,38" }, { "attribute_code": "strap_bags", "value": "61,62,65,66,67" }, { "attribute_code": "features_bags", "value": "72,74,75,78" }, { "attribute_code": "size", "value": "91" }, { "attribute_code": "erin_recommends", "value": "1" }, { "attribute_code": "sale", "value": "1" }, { "attribute_code": "marca", "value": "TEST" } ] }

When I enter on edit view product on catalog, the weight was changed,but the name didn't change!

Somebody can help me?

Thanks