cancel
Showing results for 
Search instead for 
Did you mean: 

Create custom State and status magento 2

SOLVED

Create custom State and status magento 2

Hi ,

 

I would like to create custom state as Dispatch and status as Dispatched. Please anyone can help ASAP.

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Create custom State and status magento 2

@tippanna_pawar 

 

Try it with directly adding from Database:

Modify below 2 tables:

sales_order_status

sales_order_status_state

 

First add in this table "sales_order_status" > Status = dispatched and label = Dispatch 

 

Now add in this table "sales_order_status_state" > status = dispatched, state = dispatched

 

It will work for you.

Manish Mittal
https://www.manishmittal.com/

View solution in original post

11 REPLIES 11

Re: Create custom State and status magento 2

@tippanna_pawar 

 

Sharing here few articles to follow:

 

https://www.mageplaza.com/kb/how-to-create-custom-order-status-magento-2.html

https://magecomp.com/blog/create-custom-order-status-state-programmatically-magento-2/

 

Hope this will help you.

Manish Mittal
https://www.manishmittal.com/

Re: Create custom State and status magento 2

Hi @tippanna_pawar 

You can follow the magneto documentation to create new order status and assign the order state to it.

https://docs.magento.com/user-guide/sales/order-status-custom.html

I hope it will help you!

Re: Create custom State and status magento 2

Thank for Suggetion. But still my issue not resolved. I have created Status as Dispatch but i want to create new state for that. I am unable to create new state

 

Re: Create custom State and status magento 2

Thank you for suggestion. I have created module as per the post but throwing database error on magento module Upgrade.

This is the below error

Installing data... SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`dnour`.`sales_order_status_state`, CONSTRAINT `SALES_ORDER_STATUS_STATE_STATUS_SALES_ORDER_STATUS_STATUS` FOREIGN KEY (`status`) REFERENCES `sales_order_status` (`status`) ON DELETE CASCADE), query was: INSERT INTO `sales_order_status_state` (`status`,`state`,`is_default`,`visible_on_front`) VALUES (?, ?, ?, ?) ON DUPLICATE KEY UPDATE `status` = VALUES(`status`), `state` = VALUES(`state`), `is_default` = VALUES(`is_default`), `visible_on_front` = VALUES(`visible_on_front`)

Re: Create custom State and status magento 2

Hi @tippanna_pawar 

Try the below stack solution,

https://magento.stackexchange.com/a/229948

Might be it will help you for order state.

Re: Create custom State and status magento 2

@Vimal Kumar 

 

are you still recommending to use installData? as this is deprecated in my knowledge. 

Manish Mittal
https://www.manishmittal.com/

Re: Create custom State and status magento 2

@tippanna_pawar 

 

Try it with directly adding from Database:

Modify below 2 tables:

sales_order_status

sales_order_status_state

 

First add in this table "sales_order_status" > Status = dispatched and label = Dispatch 

 

Now add in this table "sales_order_status_state" > status = dispatched, state = dispatched

 

It will work for you.

Manish Mittal
https://www.manishmittal.com/

View solution in original post

Re: Create custom State and status magento 2

Thank you brother. Your suggetion worked for me. Thanks a lot.

Re: Create custom State and status magento 2

@tippanna_pawar 

 

Definitely allow me sometime, I will provide you that too. 

Manish Mittal
https://www.manishmittal.com/