1

I was following the below tutorial https://www.integer-net.com/make-magento-2-small-again/ and removing modules etc from magento and trying to get setup:di:compile to work in my dev environment. Everything seemed fine (other than compilation) for a bit however after fiddling (removing modules and adding them back trying to get setup:di:compile to work) for a while I started getting below issue:

Running bin/magento setup:upgrade below error shows during Schema creation/updates:

Schema creation/updates:
Notice: Undefined index: inventory_stock in /var/www/magetest/public_html/vendor/magento/framework/Setup/Declaration/Schema/Db/SchemaBuilder.php on line 152

I restored all the modules (did not work) and I tried reindexing however that had no effect. Then restored an old database etc however the problem persists continuously.

The problem seems to be due to a missing table however that table seems to exist in my database. I'm running Magneto 2.3.3 however the backup database that i've had to go back from are a 2.2.7 instance that i'm now trying to upgrade.

I've also tried stating a fresh new vanilla instance and update the old database however the issue persisted again when running setup:upgrade.

I have also tried updating from 2.2.7 to 2.3.0 instead in hope that would fix however same error agian. I am out of ideas and so any simple suggestions to fix this may help me save some time!

UPDATE

OK really unhappy with what I had to go to fudge this into operation but will explain an may help someone figure out a better fix.

So I conditionally removed out the section which was giving an error for the case where the reference table was "inventory_stock":

Magento\Framework\Setup\Declaration\Schema\Db\SchemaBuilder;

        foreach ($referencesData as $referenceData) {
            //Prepare reference data
            if($referenceData['referenceTable'] != "inventory_stock") {
                $referenceData['table'] = $table;
                $referenceTableName = $referenceData['referenceTable'];
                $referenceData['column'] = $table->getColumnByName($referenceData['column']);
                $referenceData['referenceTable'] = $this->tables[$referenceTableName];
                $referenceData['referenceColumn'] = $referenceData['referenceTable']->getColumnByName(
                    $referenceData['referenceColumn']
                );

                $references[$referenceData['name']] = $this->elementFactory->create('foreign', $referenceData);
                //We need to instantiate tables in order of references tree
                if (isset($tables[$referenceTableName]) && $referenceTableName !== $tableName) {
                    $this->processReferenceKeys([$referenceTableName => $tables[$referenceTableName]], $schema);
                    unset($tables[$referenceTableName]);
                }
            }
        }

For some reason the build function was not adding the table "inventory_stock" to the tables array and when trying to process reference keys for the table "inventory_stock_sales_channel" the referenceTable "inventory_stock" did not exist so threw an error (not sure if the table shuoldn't of existed in referenceData and so threw an error because of reverse of above).

Removing the above was just a test but allowed me to get to another error about cannot create the "inventory_stock" table as it already existed.

So I decided to remove it from DB and let Magento recreate it properly.

I then removed the mod above and tried again and all worked. I had to recreate stock codes as was getting errors about stock codes not existing.

Feel this is a long way around and recreating the table correctly may have been the easiest approach however nothing seemed to work for me until Magento created it. Or possibly just deleting the table but sure I tried that.

6
  • I tried something similar as was cheesed off with bundled stuff. In the end magento install was problematic. Every time I added a new extension something had to be restored. Google yireo replace git. Take a look at composer meta packages. The bundled one works for me. That's a happy medium. Also worth highlighting that newer version of MSI (inventory) is a lot faster. This is the version that will be released with 2.3.4. Nov 26, 2019 at 21:52
  • Yeah seems bloated so much stuff I do not actually use and its not as fast as i would like sometimes! Looks interesting however that. Worried about the time involved in doing what I did in my question and that may sort it. Seems like it doesn't have a version for the 2.3.3 branch however yet tho!
    – harri
    Nov 27, 2019 at 8:58
  • Also bit concerned that it removes all optional modules when I think i'm gonna wanna keep a few, is it configurable to keep say the few that are actually used?
    – harri
    Nov 27, 2019 at 9:02
  • You've got different tiers. But ultimately you can extract the information and put what you want in composer rather than use meta package Nov 27, 2019 at 11:50
  • Yeah will hope for a 2.3.3 version soon and give a go hopefully
    – harri
    Nov 27, 2019 at 14:37

2 Answers 2

1

run command

php bin/magento indexer:reindex
4
  • Tried that i'm afraid. Thanks tho, sure it is something that simple.
    – harri
    Nov 26, 2019 at 14:14
  • try this, UPDATE cataloginventory_stock_itemSETwebsite_id= '0' WHEREcataloginventory_stock_item.website_id = '1'
    – Manoj Pal
    Nov 26, 2019 at 14:16
  • Will give it a go soon just importing broken DB again to try and fix again.
    – harri
    Nov 26, 2019 at 14:17
  • Wieredely now everything works ok. Reimported the DB don't think I changed anything and it worked fine. I'm stumped but guess I can move on atleast.
    – harri
    Nov 26, 2019 at 15:15
0

Try to import the product catalog once again or reupload the the last two catalog file. Then reindex all.

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.