0

How to add the order statuses to the permission rules in order to be able to assign a particular order status of a state to a user where he/she is able to change the status for an order only if the permission of that particular order status is granted to them.

0

Magento does not support the desired behaviour natively.

You can achieve it using the following solution though it isn't the most tidy of approaches.

You'll need to override an admin theme template, or edit the base template file though this is not recommended as it will prevent your ability to upgrade in future.

app/design/adminhtml/base/default/template/sales/order/view/history.phtml, replace lines 34 through 36 from:

<?php foreach ($this->getStatuses() as $_code=>$_label): ?>
    <option value="<?php echo $_code ?>"<?php if($_code==$this->getOrder()->getStatus()): ?> selected="selected"<?php endif; ?>><?php echo $_label ?></option>
<?php endforeach; ?>

to:

<?php
  $admin_user_role = Mage::getSingleton('admin/session')->getUser()->getRole()->getData();
  $restricted_statuses = array('Restricted Status 1', 'Restricted Status 2'); //etc
?>
<?php foreach ($this->getStatuses() as $_code=>$_label): ?>
    <?php if(in_array($_label, $restricted_statuses)): ?>
    <?php //restricted role ?>
        <?php if ($admin_user_role['role_name'] == 'Your Restricted Role'): ?>
        <?php //in which case the user has permission to access this role ?>
            <option value="<?php echo $_code ?>"<?php if($_code==$this->getOrder()->getStatus()): ?> selected="selected"<?php endif; ?>><?php echo $_label ?></option>
        <?php endif; ?>
    <?php else: ?>
    <?php //unrestricted status ?>
        <option value="<?php echo $_code ?>"<?php if($_code==$this->getOrder()->getStatus()): ?> selected="selected"<?php endif; ?>><?php echo $_label ?></option>
    <?php endif; ?>
<?php endforeach; ?>

This way, you're able to specify the restricted statuses using the $restricted_statuses array, and only provide access to the "Your Restricted Role" user.

This obviously isn't ideal as it's hard coded, but using a bit of intuition you'd be able to set up a table in the database to handle this.

  • thank you, is there any way that I override the base template in such a way that I don't lose the changes I mad or don't get any problem while the Magento is upgraded to a new version. – Reshad Zazai Mar 23 '17 at 9:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.