Skip to content

Instantly share code, notes, and snippets.

@jkaflik
Created May 27, 2013 09:54
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jkaflik/5656224 to your computer and use it in GitHub Desktop.
Save jkaflik/5656224 to your computer and use it in GitHub Desktop.
Fix for "Stock item for Product is not valid" error in Magento 1.x. It reproduces cataloginventory_stock_item using product entities.
INSERT INTO `cataloginventory_stock_item` (
`item_id` ,
`product_id` ,
`stock_id` ,
`qty` ,
`min_qty` ,
`use_config_min_qty` ,
`is_qty_decimal` ,
`backorders` ,
`use_config_backorders` ,
`min_sale_qty` ,
`use_config_min_sale_qty` ,
`max_sale_qty` ,
`use_config_max_sale_qty` ,
`is_in_stock` ,
`low_stock_date` ,
`notify_stock_qty` ,
`use_config_notify_stock_qty` ,
`manage_stock` ,
`use_config_manage_stock` ,
`stock_status_changed_auto` ,
`use_config_qty_increments` ,
`qty_increments` ,
`use_config_enable_qty_inc` ,
`enable_qty_increments` ,
`is_decimal_divided`
)
SELECT NULL , entity_id, '1', '1', '0.0000', '1', '0', '0', '1', '1.0000', '1', '0.0000', '1', '1', NOW( ) , NULL , '1', '1', '1', '0', '1', '0.0000', '1', '0', '0' FROM `catalog_product_entity`;
@francisberesford
Copy link

Thanks for this! I needed to use "INSERT IGNORE INTO" because not all my products were messed up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment