0

I run project but I got error when run php bin/magento setup:upgrade.

enter image description here

How can I fix it?

2 Answers 2

0

It seems you removed that module but the source model class still exists in your database.

The Vendor\Module\Model\Source\ClassName class is typically 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:
$catalogSetup->addAttribute(
    \Magento\Catalog\Model\Product::ENTITY,
    'gift_message_available',
    [
        //...
        '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 'Magestore\\\\Giftvoucher\\\\Model\\\\Source\\\\GiftCardTypeOptions%';

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:

SELECT *
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.

0

This class Magestore\Giftvoucher\Model\Source\GiftCardTypeOptions still exist in your code or in Database.

But this class not exist. I this Magestore_Giftvoucher deleted or class changed.

Search it and delete this.

Search in code usign CLI .

Command : grep -ri "GiftCardTypeOptions" app/

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.