0

I am using the following to remove an Item from the Mass Action menu in the orders screen, I am struggling with making it work for multiple items.

class MassAction extends \Magento\Ui\Component\MassAction
{
    private $authorization;
    public function __construct(
            \Magento\Framework\View\Element\UiComponent\ContextInterface $context,
            \Magento\Framework\AuthorizationInterface $authorization,
            array $components,
            array $data
    ) {
        $this->authorization = $authorization;
        parent::__construct($context, $components, $data);
    }

    public function prepare() {
        parent::prepare();
        $config = $this->getConfiguration();
        $allowedActions = [];
        foreach ($config['actions'] as $action) {
            if ('cancel' != $action['type']) {
                $allowedActions[] = $action;
            }
        }
        $config['actions'] = $allowedActions;       
        $this->setData('config', (array)$config);
                parent::prepare();
        $config = $this->getConfiguration();
        $allowedActions = [];
        foreach ($config['actions'] as $action) {
            if ('hold_order' != $action['type']) {
                $allowedActions[] = $action;
            }
        }
        $config['actions'] = $allowedActions;
        $this->setData('config', (array)$config);
    }
}

Can anyone assist?

0

1 Answer 1

0

The issue was some of the 'type' variables dont seem to work, if I use 'label' it works fine

foreach ($config['actions'] as $action) {
            if (('cancel' != $action['type']) and ('hold_order' != $action['type']) and ('unhold_order' != $action['type']) and ('Print Invoices' != $action['label']) and ('print_shipping_label' != $action['type']) and ('Print Packing Slips' != $action['label']) and ('Print Credit Memos' != $action['label']) and ('Print All' != $action['label'])) {
                $allowedActions[] = $action;
            }   

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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