Thursday, 13 December 2012

Shorter IDs without Site ID for Orders, Invoices and Shippments

I found it very strange that magento creates different ids for orders, invoices and shipments depending on the site_view.
Below sql statements create global ids, limit the code length to 5 plus a character prefix.
B = Orders, R = Invoices, V = Shipping
And I let all of them start with 13000.

You have to apply the script to a store without orders, invoices and shipments, otherwise you are in risk of having duplicate ids if you don't choose your prefix well.

I used to get rid of my test data.
UPDATE `magento`.`eav_entity_type` SET `increment_per_store` = '0' , `increment_pad_length` = '5' WHERE `entity_type_id` = '4'; 
UPDATE `magento`.`eav_entity_type` SET `increment_per_store` = '0' , `increment_pad_length` = '5' WHERE `entity_type_id` = '18'; 
UPDATE `magento`.`eav_entity_type` SET `increment_per_store` = '0' , `increment_pad_length` = '5' WHERE `entity_type_id` = '24'; 
UPDATE `magento`.`eav_entity_type` SET `increment_per_store` = '0' , `increment_pad_length` = '5' WHERE `entity_type_id` = '28'; 

TRUNCATE `eav_entity_store`;
ALTER TABLE `eav_entity_store` AUTO_INCREMENT=1;

insert  into `eav_entity_store`(`entity_store_id`,`entity_type_id`,`store_id`,`increment_prefix`,`increment_last_id`) values (1,4,0,'B','B13000'),(2,18,0,'R','R13000'),(3,24,0,'V','V13000');