When index I get this error: "Class Magespacex\Giftvoucher\Model\Source\TemplateOptions does not exist"

I have done this: php -f bin/magento module:disable --clear-static-content Magespacex_Giftvoucher ...and removed tables in database - and files in server.

Seams to be removed completely and only INDEX is the problem now.

Product EAV index process error during indexation process: Class Magespacex\Giftvoucher\Model\Source\TemplateOptions does not exist

1 Answer 1


Class Vendor\Module\Model\Source\ClassName is commonly used for source models. It can be declared in the following places:

  • XML files (system.xml, di.xml, UI component form)
  • a InstallData class (install script) or a data patch to add a new custom EAV attribute. For example:
        'source' => \Magento\Catalog\Model\Product\Attribute\Source\Boolean::class,

Install scripts and data patches used for modifying the database schema/data. Install scripts is the old approach, which is located in <module dir>/Setup directory, while the data patch is the new approach since Magento 2.3, located in the <module dir>/Setup/Patch/Data directory.

In case you removed the module files completely but the error still related to the source model class, it is likely that the source class was used as a source model for a custom attribute stored in the database. Therefore, you should search the source model class in the eav_attribute database table. As the source model class contain backslashes, you need to escape them by replacing \ with \\\\.

You can run the following SQL query to detect the EAV attribute record in the database:

SELECT * FROM `eav_attribute` WHERE `source_model` LIKE 'Magespacex\\\\Giftvoucher\\\\Model\\\\Source\\\\TemplateOptionsModel%';

Once you get the EAV attribute record, delete it from your database to resolve the issue.

For those who have a similar issue, which the class is stored in other columns such as backend_model, frontend_model, you can run the following SQL query to detect the EAV attribute involved:

FROM `eav_attribute`
WHERE (`backend_model` LIKE 'Vendor\\\\Module\\\\Model%' OR `frontend_model` LIKE 'Vendor\\\\Module\\\\Model%' OR `source_model` LIKE 'Vendor\\\\Module\\\\Model%');

Remember to replace Vendor and Module in the query to the vendor name and module name of the class you are looking for.

  • If this answer helps you resolve your issue, please mark it as accepted (the check symbol at the top-left corner of my answer). That indicates your issue is solved and helps others with the same issue find the verified answer easily.
    – Tu Van
    Commented Jul 29, 2023 at 5:44
  • I will try this. Commented Jul 30, 2023 at 7:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.