1

Is it possible to add dynamic massactions to admin grids?

"Dynamic" in the way that the last dropdown options depend on previous selection?

For example I want to update some attribute values. Magentos "Update Attributes" massaction does not work, because it just replaces current values.

In may case (or maybe here: Magento Update Multiselect Attribute: add 1 option (dont overwrite curent0) via script or massupdate or extension) I want to append/remove values to/from current selected values.

So I need 4 dropdowns/input fields, that depend on previous selection:

  • 1st dropdown to select action
  • 2nd to select attribute
  • 3rd to select "update type" (add/remove/replace value)
  • 4th value to change

Example observer code ...

public function addMassactionToProductGrid($observer)
{
    $block = $observer->getBlock();
    if ($block instanceof Mage_Adminhtml_Block_Catalog_Product_Grid) {
        $attributes = ...

        $block->getMassactionBlock()->addItem(
            'my_massaction',
            array(
                'label'      => Mage::helper('catalog')->__('Update Attribute Values'),
                'url'        => $block->getUrl('*/*/mycontrolleraction', array('_current' => true)),
                'additional' => array(
                    'attribute' => array(
                        'name'   => 'attribute',
                        'type'   => 'select',
                        'class'  => 'required-entry',
                        'label'  => Mage::helper('catalog')->__('Attribute'),
                        'values' => $attributes,
                    ),
                    'update_type' => array(
                        'name'   => 'type',
                        'type'   => 'select',
                        'class'  => 'required-entry',
                        'label'  => Mage::helper('catalog')->__('Update type'), # e.g. add|delete|replace
                        'values' => #??? depends on `attribute` selection,
                    ),
                    'update_value' => array(
                        'name'   => 'value',
                        'type'   => 'select', # maybe also depending on previous selection
                        'class'  => 'required-entry',
                        'label'  => Mage::helper('catalog')->__('Update Value'),
                        'values' => #??? depends on `update_value` selection,
                    ),
                ),
            )
        );
    }

    return $this;
}

Any ideas to make update_type and update_value dynamic?

Your Answer

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

Browse other questions tagged or ask your own question.