Skip to content

Instantly share code, notes, and snippets.

@cagartner
Created December 4, 2019 17:19
Show Gist options
  • Save cagartner/443511c55cf04718ff250e9bbc221115 to your computer and use it in GitHub Desktop.
Save cagartner/443511c55cf04718ff250e9bbc221115 to your computer and use it in GitHub Desktop.
Create inventory_stock_1 view for Magento 2
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` )));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment