Skip to content
This repository has been archived by the owner on Jul 11, 2023. It is now read-only.

Can't install on Magento 2 enterprise version. #3

Open
tarasovd opened this issue Feb 10, 2023 · 0 comments
Open

Can't install on Magento 2 enterprise version. #3

tarasovd opened this issue Feb 10, 2023 · 0 comments

Comments

@tarasovd
Copy link

tarasovd commented Feb 10, 2023

UpgradeData script failing on Magento 2 enterprise.

Fix:

diff --git a/Setup/UpgradeData.php b/Setup/UpgradeData.php
index db4f834..8b0f43c 100644
--- a/Setup/UpgradeData.php
+++ b/Setup/UpgradeData.php
@@ -319,7 +319,6 @@ class UpgradeData implements UpgradeDataInterface
 
     protected function setDefaultIsImportedValuesForExistingCategories(ModuleDataSetupInterface $setup)
     {
-        $existingCategoryIds = $this->categoryCollection->getAllIds();
         $isImportedAttributeId = $this->eavAttribute->getIdByCode(Category::ENTITY, InstallData::IS_IMPORTED);
 
         if (empty($existingCategoryIds)) {
@@ -328,8 +327,17 @@ class UpgradeData implements UpgradeDataInterface
 
         $connection = $setup->getConnection();
         $tableName = $setup->getTable('catalog_category_entity_int');
-        $columnName = 'entity_id';
-        $fkColumnName = $connection->tableColumnExists($tableName, $columnName) ? $columnName : 'row_id';
+        $hasRowId = $connection->tableColumnExists($tableName, 'row_id');
+        $fkColumnName = $hasRowId ? 'row_id' : 'entity_id';
+        $existingCategoryIds = [];
+
+        if ($hasRowId) {
+            $existingCategoryIds = $this->categoryCollection
+                ->addFieldToSelect('row_id')
+                ->getColumnValues('row_id');
+        } else {
+            $existingCategoryIds = $this->categoryCollection->getAllIds();
+        }
 
         $data = [];
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant