0

I am a newbie Magento 2. I have set up a Magento site run on Ubuntu 20.04. Everything is Ok. The site works normally until a nice day. It showed the error as below and cannot allow creating new orders anymore.

Can you take a look at it and help me to resolve it?

Thank you so much.

  • OS: ubuntu 20.04
  • Magento 2.4.2
[2022-01-05 12:47:13] main.CRITICAL: Exception message: SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`magento2`.`sales_order_item`, CONSTRAINT `SALES_ORDER_ITEM_ORDER_ID_SALES_ORDER_ENTITY_ID` FOREIGN KEY (`order_id`) REFERENCES `sales_order` (`entity_id`) ON DELETE CASCADE), query was: INSERT INTO `sales_order_item` (`order_id`, `quote_item_id`, `store_id`, `product_id`, `product_type`, `product_options`, `weight`, `is_virtual`, `sku`, `name`, `description`, `applied_rule_ids`, `additional_data`, `is_qty_decimal`, `qty_backordered`, `qty_ordered`, `base_cost`, `price`, `base_price`, `original_price`, `base_original_price`, `tax_percent`, `tax_amount`, `base_tax_amount`, `discount_percent`, `discount_amount`, `base_discount_amount`, `row_total`, `base_row_total`, `row_weight`, `base_tax_before_discount`, `tax_before_discount`, `price_incl_tax`, `base_price_incl_tax`, `row_total_incl_tax`, `base_row_total_incl_tax`, `discount_tax_compensation_amount`, `base_discount_tax_compensation_amount`, `gift_message_id`, `gift_message_available`, `free_shipping`, `weee_tax_applied`, `weee_tax_applied_amount`, `weee_tax_applied_row_amount`, `weee_tax_disposition`, `weee_tax_row_disposition`, `base_weee_tax_applied_amount`, `base_weee_tax_applied_row_amnt`, `base_weee_tax_disposition`, `base_weee_tax_row_disposition`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)

1 Answer 1

0

It just simply means that the value for column project_id on table comments you are inserting doesn't exist on table projects. Bear in mind that the values of column project_id on table comments are dependent on the values of ID on table Projects.

The value 50dc845a-83e4-4db3-8705-5432ae7aaee3 you are inserting for column project_id does not exist on table projects.

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.