Magento 2.3 introduced a view table which causes issue with import of mysql dump. What's it for?

by Dominic Xigen   Last Updated May 15, 2019 23:09 PM

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?



Related Questions


Updated October 03, 2018 13:09 PM

Updated March 18, 2019 08:09 AM

Updated January 21, 2019 08:09 AM

Updated August 14, 2015 17:04 PM

Updated April 13, 2015 20:04 PM