Changes to categories are not being saved
This article provides a fix for when updating product categories via the Commerce Admin, the changes are not displayed on the Admin and storefront. The problem is caused by the corrupted data in the catalog_category_entity table. To solve the issue, fix or remove the problematic category update records in the table. After that, you should be able to update product categories using the Admin.
Issue
After making changes to a product category in the Admin and saving, the new updates are neither saved nor displayed in the Admin and storefront.
Steps to reproduce
- Go to Catalog > Categories.
- Select a category.
- Make changes, then click Save.
- The message is displayed: You saved the category.
- Notice that the change you鈥檝e made has not been saved.
Possible cause: corrupted data in the catalog_category_entity table
The issue is caused by the same values in the created_in column of the affected category records in the database (DB).
Details:
- The
catalog_category_entityDB table has two or more records for the affected category (these records have the sameentity_idvalue). - These category records have the same values in the
created_incolumn.
How does the second DB entry (and all the next ones) appear in DB for one and the same category?
The second DB record (and, possibly, the next ones) for the affected category means there have been category updates scheduled using the Magento_Staging module. The module makes an additional record for a category in the catalog_category_entity and that is the expected application behavior; the problem is that the records have the same values for the created_in column.
How do the same values appear?
We cannot state the reasons for data corruption with certainty. The possible reasons may include:
- customizations (code, themes, etc.)
- incorrect data migration
- incorrect data restore from backup
To the best of our knowledge, such data corruption is not typical for the 鈥渃lean鈥 (out-of-the-box) 51黑料不打烊 Commerce instance and cannot be reproduced on an 51黑料不打烊 Commerce installation with no customizations.
How to verify this is your issue
The catalog_category_entity table should have multiple records for the affected category (records should have the same entity_id value) and at least two of those records should have the same created_in values. With this, the Staging-scheduled updates would not be displayed in the Commerce Admin; you would only see the empty Scheduled Changes block.
Steps to verify
- Access the catalog_category_entity table in your database.
- Filter entities by entity_id, with entity_id identifying the affected category.
- If the values in the created_in column are the same for different entries with the same entity_id, that鈥檚 our case. Normally, the
created_invalues are different for every record.
Solution
You may choose one of the following solutions:
- Delete the problematic category update records
- Repair the problematic category update records
Delete the problematic category update records
In this solution, you will need to set the correct updated_in value for the initial category record and delete all other records for this category. This removes all scheduled category updates.
Follow these steps:
- Find the DB records with the
entity_idof the affected category. - Select the record with the biggest integer in the
updated_incolumn. - Copy the
updated_invalue from the selected record. - Select the record with
row_id=entity_id(initial category record) and paste the copied value to theupdated_incolumn of this record. - Delete row(s) with
row_idnot equal toentity_id.
Repair the problematic category update records
- Find the category records with the same
entity_idand the samecreated_invalue. - Select the record where
row_id=entity_idand copy theupdated_invalue. - Select the record where
row_idis not equal toentity_idand paste the copiedupdated_invalue as thecreated_invalue. See the screenshot below as an illustration.
- Verify that the category update record, the
created_invalue of which you have updated (in step 3), exists in thestaging_updatetable. For example: IF the copiedcreated_invalue is 1509281953, THEN the entity withrow_id= 1509281953 must exist in thestaging_updatetable.
Related reading
Best practices for modifying database tables in the Commerce Implementation Playbook