cancel
Showing results for 
Search instead for 
Did you mean: 

modifica descrizione prodotto Magento2

SOLVED

modifica descrizione prodotto Magento2

Buongiorno a tutti.

 

Sto tentando di eseguire la modifica dei parametri di un prodotto tramite API Rest di Magento2.

Eseguo la chiamata

 

"http://MIOPERCORSO:8080/rest/V1/products/{"product":{"id":"1","sku":"ABCDEF","custom_attributes":{"attribute_code":"Description","value":"PROVA"}},"saveOptions":true}"

 

ma mi viene restituito l'errore

 

[messageSmiley Tonguerotected] => Client error: `PUT http://MIOPERCORSO:8080/rest/V1/products/ABCDEF/%7B%22product%22:%7B%22id%22:%223194%22,%22sku%22:%22ABCDEF%22,%22custom_attributes%22:%7B%22attribute_code%22:%22Description%22,%22value%22:%22prova%22%7D%7D,%22saveOptions%22:true%7D` resulted in a `404 Not Found` response:
{"message":"Request does not match any route."}

 

ma il prodotto nel DB di Magento esiste.

 

Qualche suggerimento?

 

Grazie

1 ACCEPTED SOLUTION

Accepted Solutions

Re: modifica descrizione prodotto Magento2

Thank you.

I've tryed this solution in Postman and it works, I can read new description by the execution of GET method for the call, but Description field in backend session for this product didn't change. Have I modify another field instead of custom_attributes > "attribute_code": "description" ? 

View solution in original post

2 REPLIES 2

Re: modifica descrizione prodotto Magento2

Hello @roberto_de ga

 

"Request does not match any route" means you are not calling API properly something wrong. 

 

To create product, we can use:

  • POST: /V1/products

For updating:

  • PUT: /V1/products/{sku}

In your case, your code should be:

$productData = [
        'attribute_set_id'  => 4,
        "type_id": "simple",
        "sku": "test-SKU",
        "name": "Test",
        "price": 100,
        "status": 1,
        'custom_attributes' => [
                ['attribute_code' => 'description', 'value' => 'Test Description' ],
                ['attribute_code' => 'short_description', 'value' => 'Test Short Description' ],
            ]
    ];

The JSON body:

 {
  "product": {
    "sku": "test-SKU",
    "name": "Test",
    "attribute_set_id": 4,
    "price": 100,
    "status": 1,
    "custom_attributes": [
      {
        "attribute_code": "description",
        "value": "Test Description"
      },
      {
        "attribute_code": "short_description",
        "value": "Test Short Description"
      }
    ]
  }
}

 

Please follow and let me know if you are still facing any issue. 

Manish Mittal
https://www.manishmittal.com/

Re: modifica descrizione prodotto Magento2

Thank you.

I've tryed this solution in Postman and it works, I can read new description by the execution of GET method for the call, but Description field in backend session for this product didn't change. Have I modify another field instead of custom_attributes > "attribute_code": "description" ?