0

While Save Product I got Error. I don't know what is the problem suddenly it happen

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '16963-1' for key 'UNQ_CATALOGINVENTORY_STOCK_ITEM_PRODUCT_ID_STOCK_ID', query was: INSERT INTO cataloginventory_stock_item (product_id, stock_id, qty, use_config_min_qty, is_qty_decimal, use_config_backorders, use_config_min_sale_qty, use_config_max_sale_qty, is_in_stock, low_stock_date, use_config_notify_stock_qty, use_config_manage_stock, stock_status_changed_auto, use_config_qty_increments, use_config_enable_qty_inc, is_decimal_divided) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)

1 Answer 1

4

Change the line

$product->save();

to

$product->getResource()->save($product);

Hope this will help

7
  • 1
    Can you please tell me the file location
    – Magento 2
    Commented May 18, 2016 at 5:35
  • did you changed any file before or what is the reason you are getting this error?
    – Charlie
    Commented May 18, 2016 at 5:39
  • I din't change anything while save product i got this error
    – Magento 2
    Commented May 18, 2016 at 5:42
  • Did you created any product attribute from admin backend?
    – Charlie
    Commented May 18, 2016 at 5:54
  • No recently i din't create
    – Magento 2
    Commented May 18, 2016 at 5:55

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.