1

If you mysql dump a magento 2.3 store and try to import it elsewhere you get an issue due the the format of the view import query.

The problem part is this:

CREATE ALGORITHM=UNDEFINED DEFINER=`PUT_YOUR_DATABASE_USER_NAME_HERE`@`localhost` SQL SECURITY INVOKER VIEW `inventory_stock_1`  AS  select distinct `legacy_stock_status`.`product_id` AS `product_id`,`legacy_stock_status`.`website_id` AS `website_id`,`legacy_stock_status`.`stock_id` AS `stock_id`,`legacy_stock_status`.`qty` AS `quantity`,`legacy_stock_status`.`stock_status` AS `is_salable`,`product`.`sku` AS `sku` from (`cataloginventory_stock_status` `legacy_stock_status` join `catalog_product_entity` `product` on(`legacy_stock_status`.`product_id` = `product`.`entity_id`)) ;

You need elevated permissions. The solution is this:


CREATE
OR REPLACE
VIEW `inventory_stock_1` AS select
    distinct `legacy_stock_status`.`product_id` AS `product_id`,
    `legacy_stock_status`.`website_id` AS `website_id`,
    `legacy_stock_status`.`stock_id` AS `stock_id`,
    `legacy_stock_status`.`qty` AS `quantity`,
    `legacy_stock_status`.`stock_status` AS `is_salable`,
    `product`.`sku` AS `sku`
from
    ( `cataloginventory_stock_status` `legacy_stock_status`
join `catalog_product_entity` `product` on
        (( `legacy_stock_status`.`product_id` = `product`.`entity_id` )));

My question is what is this view table used for? And why a view?

2 Answers 2

1

You don't need elevate permissions.Try this:

wget https://files.magerun.net/n98-magerun2.phar
php n98-magerun2.phar db:dump

Done. Now you can import DB without problems.

0

It's part of the new Magento 2 Multi Source Inventory feature

A view for performance reasons and maintainability. No point in creating yet a other index table that needs to managed when the data is already there but in other tables.

1
  • It's worth highlighting that you have one of these views for each store view. The above example is for store ID 1 Commented Sep 24, 2019 at 19:43

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.