I'm facing an issue while trying to create a category in Magento 2.4.7-p2 The following error appears when i click categories from Catalog from the Magento 2 Admin
1 exception(s): Exception #0 (ReflectionException): Class "Magento\Catalog\Model\Category\Attribute\Backend\DefaultSortby" does not exist
Despite trying these steps, the issue persists. Has anyone encountered a similar issue or knows what might be causing this? Any help or guidance would be greatly appreciated!
Hello @mahade hassan_khan,
1. Disable all third party module once.
2. run all commands and check.
3. if issue still persists, then check any attribute using that class in database.
4. Check eav_attribute table backend class in database.
Let me know if you find anything in database table.
I hope it helps!
It looks like you're missing the DefaultSortby class in Magento 2.4.7-p2. Here’s what you can try:
Same error i found.
Check than in `eav_attribute` table `default_sort_by` attribute `backend_mode` save wrong value need to change that with "Magento\Catalog\Model\Category\Attribute\Backend\Sortby" which is working now.
Because no such file as DefaultSortby.php
Hello @mahade hassan_khan,
Class "Magento\Catalog\Model\Category\Attribute\Backend\DefaultSortby" does not exist, suggests that Magento is trying to reference a class that either doesn't exist in the Magento 2.4.7-p2 version or there is some misconfiguration within your setup.
Magento may have removed or renamed certain classes in version 2.4.7-p2. Verify if the DefaultSortby class has been deprecated or moved to a different location by checking the release notes for Magento 2.4.7-p2 or by searching for this class in the Magento source code repository.
You can run this command inside the Magento root directory to search for references:
grep -R "DefaultSortby" vendor/magento/
it has been moved to: Magento\Catalog\Block\Adminhtml\Category\Helper\Sortby\DefaultSortby.php this path.
If you find that the missing class is required in some code, you can remove the reference or modify the code to use alternative logic for handling category sorting.
For sorting categories, you might instead rely on core functionality or extend category attribute models.
Sometimes, category attributes are referenced in the database, especially in eav_attribute tables. Look for any custom entries that might be linked to DefaultSortby. If necessary, remove or update those entries.
If you recently installed any new modules or made changes to custom code, try disabling those modules and re-enable them one by one to identify if one of them is causing the issue.
If the issue will be resolved, Click Kudos & Accept as a Solution.