Search code examples
magento2

Magento 2.4: Unable to apply data patch Magento\CatalogRuleSampleData\Setup\Patch\Data\InstallCatalogRuleSampleData


Getting the below error while trying to install sample data and upgrading the setup in Magento 2.4.2-p1 Error: Unable to apply data patch Magento\CatalogRuleSampleData\Setup\Patch\Data\InstallCatalogRuleSampleData for module Magento_CatalogRuleSampleData. Original exception message: Rolled back transaction has not been completed correctly.

Please help.


Solution

  • Syntax error(s) are existed in the following sample csv files.

    /vendor/magento/module-catalog-rule-sample-data/fixtures/catalog_rules.csv
    /vendor/magento/module-sales-rule-sample-data/fixtures/sales_rules.csv
    

    2 solutions for the above issue:

    1. Fix and validate the above CSVs manually or online tool like https://csvlint.io/

    2. Comment line of code, calling above CSVs

      \Magento\CatalogRuleSampleData\Setup\Installer.php
      \Magento\SalesRuleSampleData\Setup\Installer.php
      
      like:
          /**
           * {@inheritdoc}
           */
          public function install()
          {
              //$this->rule->install(['Magento_CatalogRuleSampleData::fixtures/catalog_rules.csv']);
          }