Skip to content

Instantly share code, notes, and snippets.

@janssens
Last active June 4, 2018 13:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save janssens/009d2988c4b6da1f53d08f070043a327 to your computer and use it in GitHub Desktop.
Save janssens/009d2988c4b6da1f53d08f070043a327 to your computer and use it in GitHub Desktop.
Magento sql script to regenerate eav_entity_store table.
TRUNCATE eav_entity_store;
INSERT INTO eav_entity_store (entity_type_id,store_id,increment_prefix,increment_last_id)
SELECT
'5' AS entity_type_id,
store_id AS store_id,
store_id AS increment_prefix,
increment_last_id AS increment_last_id
FROM (SELECT store_id as store_id, MAX(increment_id) as increment_last_id FROM sales_flat_order WHERE store_id is not NULL GROUP BY store_id) as tmp;
INSERT INTO eav_entity_store (entity_type_id,store_id,increment_prefix,increment_last_id)
SELECT
'6' AS entity_type_id,
store_id AS store_id,
store_id AS increment_prefix,
increment_last_id AS increment_last_id
FROM (SELECT store_id as store_id, MAX(increment_id) as increment_last_id FROM sales_flat_invoice WHERE store_id is not NULL GROUP BY store_id) as tmp;
INSERT INTO eav_entity_store (entity_type_id,store_id,increment_prefix,increment_last_id)
SELECT
'7' AS entity_type_id,
store_id AS store_id,
store_id AS increment_prefix,
increment_last_id AS increment_last_id
FROM (SELECT store_id as store_id, MAX(increment_id) as increment_last_id FROM sales_flat_creditmemo WHERE store_id is not NULL GROUP BY store_id) as tmp;
INSERT INTO eav_entity_store (entity_type_id,store_id,increment_prefix,increment_last_id)
SELECT
'8' AS entity_type_id,
store_id AS store_id,
store_id AS increment_prefix,
increment_last_id AS increment_last_id
FROM (SELECT store_id as store_id, MAX(increment_id) as increment_last_id FROM sales_flat_shipment WHERE store_id is not NULL GROUP BY store_id) as tmp;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment