0

Setup Data Patch script is executed successfully after running setup:upgrade command. Now i want to execute same script with public static function getVersion() function.

Module version is :

<?xml version="1.0"?>
setup_version="1.0.0" module_version="1.0.0"

Script function is :

use Magento\Framework\Setup\Patch\PatchVersionInterface;

/**
 * AddCategoryAttributes Class for adding category attributes.
 *
 */
class AddCategoryAttributes implements DataPatchInterface, PatchRevertableInterface, PatchVersionInterface

    public static function getVersion()
        {
            return '2.0.0';
        }

After running setup:upgrade command attribute value isn't updated.

5
  • Are you try to apply higher version 2.0.0 to setup_version 1.0.0? Jun 17, 2022 at 10:07
  • I have tried both higher and lower version. Jun 17, 2022 at 11:04
  • What is Magento version are you use? For 2.4.x you can remove setup_version and module_version at all. What is the reason to use versioned patches? Is your patch already exists in table patch_list? Jun 17, 2022 at 11:10
  • patch is already exist in patch_list, i want to use same patch file. Magento ver. 2.4.0-p1 Jun 17, 2022 at 11:29
  • In this case you need to remove it from patch_list first. Other way it will not be processed. Jun 17, 2022 at 11:57

1 Answer 1

0

As per my understanding.

If you have already ran setup_upgrade before, there is a table in the database called patch_list that will be filled because patches are only executed once. You could go in the database and delete the entry and then run setup_upgrade again.

Below are Steps to run existing data patches file in Magento 2

  • Step 1: Open the “patch_list” table of the website database.
  • Step 2: delete the entry of your existing patch.
  • Step 2: run setup:upgrade command to run your patch file.

THANKS.

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.