cancel
Showing results for 
Search instead for 
Did you mean: 

Magento\Catalog\Model\Category\Attribute\Backend\DefaultSortby" does not exist in Magento 2.4.7-p2

Magento\Catalog\Model\Category\Attribute\Backend\DefaultSortby" does not exist in Magento 2.4.7-p2

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

What I've tried so far:

  1. Ran php bin/magento setup:di:compile, php bin/magento setup:upgrade, and php bin/magento cache:flush.
  2. Checked the file path vendor/magento/module-catalog/Model/Category/Attribute/Backend/DefaultSortby.php, and it seems that the file doesn't exist.
  3. Reinstalled the magento/module-catalog using composer remove and composer require.
  4. Disabled third-party modules to check for any extension conflicts.
  5. Verified file permissions and recompiled static content.
  6. Enabled developer mode and checked logs in var/log/exception.log and var/log/system.log.

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!

4 REPLIES 4

Re: Magento\Catalog\Model\Category\Attribute\Backend\DefaultSortby" does not exist in Magento 2

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!

Problem Solved ? Click on 'Kudos' & Accept as Solution ! Smiley Happy

Re: Magento\Catalog\Model\Category\Attribute\Backend\DefaultSortby" does not exist in Magento 2

It looks like you're missing the DefaultSortby class in Magento 2.4.7-p2. Here’s what you can try:

  1. Confirm Version: Make sure your Magento version is 2.4.7-p2.
  2. Check Documentation: Verify if the class was deprecated or removed in this version.
  3. Review Custom Code: Ensure no custom modules are referencing the missing class.
  4. Update Modules: Ensure all third-party modules are compatible and updated.
  5. Database Check: Run php bin/magento setup:db-data:upgrade to sync the database schema.
  6. Consult Resources: Look for similar issues on Magento forums or GitHub.

Re: Magento\Catalog\Model\Category\Attribute\Backend\DefaultSortby" does not exist in Magento 2

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

Re: Magento\Catalog\Model\Category\Attribute\Backend\DefaultSortby" does not exist in Magento 2

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.