Contributions 2 min read

# Classification store key deletion fix

Check out how one of our Pimcore developers helped improve Pimcore by fixing issues in Pimcore's classification store!

Last updated on 24 September, 2021

## Key takeaways

1. Deleting a key from a Pimcore classification store did not remove it from the groups containing it, so objects still showed the deleted key as a field.
2. Pimcore soft-deletes classification store keys by setting their enabled attribute to 0 instead of removing them from the database.
3. The fix removes a key from all its groups whenever the key is updated with enabled set to 0, avoiding unnecessary data entry and database growth.

## **What was the issue?**

The problem was with classification store keys. When you delete the key from the classification store it wouldn’t delete it from the classification store group that contains it. That leads to objects still having deleted keys as their field.

## **How did you solve it?**

Problem was that the Pimcore team implemented soft delete of the classification store keys. Instead of calling a function that deletes the key from the database, it calls a function that updates that key and sets its attribute “enabled” to 0.

I added a condition in the function that updates the key, that checks if the field that is being updated is “enabled” and is being updated to value 0. If the condition is true then it would remove the key from all the groups that contained it.

## **Why is this fix important?**

This is important because classification store keys are used for making object fields that not all instances of objects contain. And if we remove a key from a classification store it means that for some reason we don’t need that information anymore. It could be because all instances of objects now must have that attribute or because that attribute is not used anymore.

No matter what is the reason we wouldn’t need to fill out that attribute anymore, so if we delete the key from a classification store but it still persists in the classification store group we would still need to fill that attribute. It leads to having to do more work, having more data in the database, and ever so slightly slowing down the page loading time.

## **How does it feel to contribute to a platform such as Pimcore?**

The feeling is amazing. Knowing that anyone can contribute to something this big is fantastic. Even while contributing to the platform, during the merge request, someone from the Pimcore development team took their time to explain something to me. Also, he gave me some advice on how to make my code even more optimized and better overall.

And if you want to check out this [pull request](https://github.com/pimcore/pimcore/pull/8579), just follow the link!

## Related

[Contributions **Fix for image assets that don’t have set dimensions** Tomislav, our Pimcore developer, has done it again and his new pull request has been accepted. Image assets have been causing some lesser issues, and now the issue… 1 min read](https://factory.dev/pimcore-knowledge-base/contributions/image-assets-fix) [Contributions **Validation errors with subItems without context stack fix** Our Pimcore developer, Tomislav, has solved another issue on the Pimcore platform. Find out why this pull request is important and what use will users have from this… 1 min read](https://factory.dev/pimcore-knowledge-base/contributions/validation-errors-fix) [Contributions **Added async option to headscript fix** Check out one of our Pimcore developers helped add the async option to the headscript, and bringing closer the release of Pimcore X! 1 min read](https://factory.dev/pimcore-knowledge-base/contributions/added-async-option-headscript-fix)

---

Source: https://factory.dev/pimcore-knowledge-base/contributions/classification-store-key-deletion-fix
