I have a system that generates quotes, then submits the quotes, which processes a payment. The system is pretty standard: nothing really complicated is going on. The quotes have a single product in them.
After the payment is processed, Magento saves the Order and the payment. However, sometimes we get an exception:
PDOException: SQLSTATE: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (sales_order_address, CONSTRAINT SALES_ORDER_ADDRESS_PARENT_ID_SALES_ORDER_ENTITY_ID FOREIGN KEY (parent_id) REFERENCES sales_order (entity_id) ON DELETE CASCADE) in /var/www/html/vendor/magento/zendframework1/library/Zend/Db/Statement/Pdo.php:228
This error suggests to me that it is trying to save the sales_order_address for a non-existent sales_order record, but why would that happen?
The payment was processed successfully on the backend but there is nothing recorded in the database to indicate that. Retrying the same quote again with the same input data usually results in success – the error appears to be transient.
How can I figure out what is causing the sales_order record to be deleted? How is this even possible? I tried searching the Magento code for a transaction rollback that swallows an exception, but didn’t find any. We are using a third-party Stripe payment module but the order-saving part happens after the payment was successfully placed. From what I can see whatever error is happening here is entirely in the core code. The error is happening on the latest (2.1.11) version.
We have this Magento 2.1 project running Production mode with “Update on save” mode for all indexes
Our customer manages catalog himself, and reported us some stock issues. Problem was changing quantity for a new product was not working. Process apparently ends fine, regarding the admin message (“Product was saved ok”) but stock was not changed. We look in Magento log files, but we don’t see any related report there
Our solution, finally, was to change indexes to “Update by schedule” and then force a reindex by console command. This solution, as far as I understand, means there is something wrong with that partial reindex fired when saving a product with “Update on save” index mode. What I am asking is for a confirmation about this… should not this problem be reported in Magento log files?
Assuming there is something wrong with our catalog data, I’d like to trace the problem, so I’d like to know which processes (the complete code trace) are fired after a product save in admin, with “Update on save” index mode. In this case, I suppose catalog_inventory ones are the most relevant
Apart from that, and checking the catalog, we’ve noticed some configurable products were sharing simple products, which is rare & we are not sure if could be the origin of the problem (although we assume system wouldn’t let to do that if that’s not allowed). Maybe this could have registered some wrong data in catalog database tables, and causing the problems with partial reindex? If that’s the case… Where can I find in database which data is pending to be processed in the next full reindex process?
I’m starting with an image url as the code implies. I think I have to use MagentoFrameworkApiDataImageContentInterface, MagentoCatalogModelWebapiProductOptionTypeFileProcessor and maybe curl, but I’m unsure how to proceed.
then I am planning to add this new Quote Item to convert into Order Item. But using the above code, All Quote Items are deleted and all grand total and subtotal in quote set to 0.
My question is: What is correct way to modify the existing Order ?
Like in sales_order_item table we have the field qty_canceled, Using the below code I can cancel the complete Item ordered qty. But when I am saving the order, Subtotal and Grand total all are set to 0.