backend_prod_mass_actions

Customizes the list of available bulk actions in the “Catalog → Products” section in the Webasyst 2 interface.

Shop-Script

Input (passed by reference)


  • $params['actions']: Array of data of the available bulk product actions, which you can modify in your plugin’s code; e.g., hide some default groups or actions or add your custom ones.

    Added array items of your custom groups and actions must constitute sub-arrays with the following keys:

    • id: (for groups and actions) String identifier starting with the plugin’s identifier to avoid conflicts with other plugins.

    • name: (for groups and actions) Localized name of a group or an action.

    • icon: (only for actions) HTML/SVG code of an action icon.

    • pinned: (only for actions) Flag corresponding to the display of an action link in the horizontal bar. If no Boolean true is specified then an action link is visible only in the vertical pop-up menu.

    • action_url: (only for actions) URL to which an AJAX POST request must be sent, with the transfer of selected products’ list hash in POST parameter 'products_hash'. The controller processing requests to the specified URL must be capable of executing the selected action.

    • redirect_url: (only for actions) URL to which a user must be redirected, with the transfer of selected products’ list hash in GET parameter 'products_hash'. The controller processing requests to the specified URL must be capable of executing the selected action. This value can be specified only if 'action_url' is empty.

    • dialog_url: (only for actions) URL to which an AJAX POST request must be sent, with the transfer of selected products’ list hash in POST parameter 'products_hash', to open a waDialog dialog. This value can be specified only if action_url and redirect_url are empty.



      A controller processing requests to this URL must return HTML code to be displayed in the dialog. Any JavaScript code which must be executed once a dialog has been displayed must be passed as a handler for wa_dialog_ready event of the dialog’s jQuery object.



      The event parameters array contains

      • selected action’s properties,

      • contents of the sent POST request,

      • dialog object,

      • dialog’s jQuery object.



    • custom_handler: (only for actions) An equivalent of true if selection of the action must execute custom JavaScript code. This value can be specified only if action_url, redirect_url and dialog_url are empty. Custom JavaScript code must be passed as a handler for the wa_custom_mass_action event of the jQuery object with selector '#js-products-page-content'.



      The event parameters array contains

      • selected action’s properties,

      • contents of the sent POST request.



    • actions: (only for action groups) Array of a list of actions which must be contained in a particular group. Each action in this array must be represented by a sub-array with parameters listed above as available for actions.



… your plugin code …

Output

Shop-Script

Plugin code example

PHP

public function backendProdMassActions(&$params)
{
    $wa_app_url = wa()->getAppUrl(null, true);

    $params['actions']['organize']['actions'][] = [
        'id' => 'myplugin_action_1',
        'pinned' => true,
        'name' => _wp('My plugin’s action 1'),
        'icon' => '<i class="fas fa-user"></i>',
        'redirect_url' => $wa_app_url . 'myplugin/one/',
    ];

    $params['actions']['myplugin_group'] = [
        'id' => 'myplugin_group',
        'name' => _wp('My plugin’s action group'),
        'actions' => [
            [
                'id' => 'myplugin_action_2',
                'name' => _wp('My plugin’s action 2'),
                'icon' => '<i class="fas fa-user"></i>',
                'action_url' => $wa_app_url . 'myplugin/two/',
            ]
        ],
    ];
}