We wiil add entires on tables “sales_order_status” and “sales_order_status_state”.
In your installer, we have to put this code :

<?php
$installer = $this;
 
// Our tables
$statusTable = $installer->getTable('sales/order_status');
$statusStateTable = $installer->getTable('sales/order_status_state');
 
// Add statuses
$installer->getConnection()->insertArray(
    $statusTable,
    array(
        'status',
        'label'
    ),
    array(
        array('status' => 'my_custom_status1', 'label' => 'Status 1'),
        array('status' => 'my_custom_status2', 'label' => 'Status 2'),
        array('status' => 'my_custom_status3', 'label' => 'Status 3'),
        array('status' => 'my_custom_status4', 'label' => 'Status 4'),
    )
);
 
// Mapping status/state
$installer->getConnection()->insertArray(
    $statusStateTable,
    array(
        'status',
        'state',
        'is_default'
    ),
    array(
        array(
            'status' => 'my_custom_status1',
            'state' => 'processing', /* canceled, closed, complete, new, processing, holded, payment_review, pending_payment */
            'is_default' => 0
        ),
        array(
            'status' => 'my_custom_status2',
            'state' => 'canceled', 
            'is_default' => 0
        ),
        array(
            'status' => 'my_custom_status3',
            'state' => 'my_custom_state', /* You can associate custom states */
            'is_default' => 0
        ),
        array(
            'status' => 'my_custom_status4',
            'state' => 'my_custom_state', 
            'is_default' => 1 /* This field will put your status by default for te state */
        ),
    )
);

Your new statuses are now visible on the backoffice.

Add order states and statuses with installer
Tagged on:         

Leave a Reply

Your email address will not be published. Required fields are marked *

We use cookies to ensure that we give you the best experience on our website.
Ok