Drupal Commerce VBO (commerce_product) ends with no Action

Created on 8 June 2024, 17 days ago
Updated 25 June 2024, 1 day ago

Implementation of custom Drupal Commerce (VBO) Actions

Create a custom action like:

/**
* Commerce Price update action.
*
* @Action(
* id = "commerce_price_adjust",
* label = @Translation("Update Price of an Commerce Item"),
* confirm = TRUE,
* requirements = {
* "_permission" = "access commerce administration pages",
* },
* type = "commerce_product"
* )
*/
+ the necessary class extending ViewsBulkOperationsActionBase (execute Method)

The missing Task -> /core/modules/views/src/Plugin/views/field/BulkForm.php:474 should not get involved (action definition should be present in form_state->getValue('action');

Please provide the necessary documentation for such implementation. BTW, current DC Actions integration does not work. In my View there is a group by Commerce Product and listing of Commerce Product Item. Publish/Unpublish Products are not working to.

Action definition is working fine. Only after triggering the Action, there is an error of "No With selection option selected." - Action is meant here.

API changes

Tried to implement a simple "system.action.commerce_price_adjust.yml" - no improvements by that either. It seems that integration of VBO for Commerce Products is not working. Any Help would be appreciated.

πŸ› Bug report
Status

Fixed

Version

4.3

Component

Core

Created by

πŸ‡©πŸ‡ͺGermany flefle

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @flefle
  • πŸ‡©πŸ‡ͺGermany flefle
  • πŸ‡©πŸ‡ͺGermany flefle
  • πŸ‡©πŸ‡ͺGermany flefle

    The ones dealing with this issue, please consider to add an config/install/system.action.commerce_price_adjust.yml before enabling your Module (maybe update hook) or implement a post enable process (Route + Controller) running following code:

    try {
    $entity_type_manager = \Drupal::entityTypeManager();
    $module_handler = \Drupal::moduleHandler();

    // Save the bulk delete action to config.
    $config_install_path = $module_handler->getModule('mbkovanie')->getPath() . '/' . InstallStorage::CONFIG_INSTALL_DIRECTORY;
    $storage = new FileStorage($config_install_path);
    $storageRead = $storage->read('system.action.commerce_price_adjust');
    $entity_type_manager
    ->getStorage('action')
    ->create($storageRead)
    ->trustData()
    ->save();
    } catch (\Exception $e) {
    return new Response('Already exists.');
    }

    .... fun fact, if you are running a Commerce Module that evolved meanwhile, it is possible that the DC Actions are not active (available) and should be reinitialised by a similar process. My issue was solved by this, and wanted to provide the community my solution. Happy coding.

  • Status changed to Fixed 16 days ago
  • πŸ‡©πŸ‡ͺGermany flefle
  • πŸ‡΅πŸ‡±Poland Graber

    Thank you for sharing your findings, hopefully it’ll help someone.
    Basically the core bulk form needs that extra configuration while the Views Bulk Operations field doesn’t, it discovers all available actions.

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.69.0 2024