Magento – Product Chooser in Custom Module

product-chooser

I am wondering if this is possible.

I would like to create same functionality as this image in my custom module.

enter image description here

I could use a widget- product chooser, however that is letting me choose only one product. I need to select more than one product.

I will have just a button where I can click and then it will render the product chooser grid and then when selected multiple items, it sends id or sku in the input field.

Then later on I will save this info in to database.

Please suggest.

Best Answer

This feature relies heavily on the Javascript vor the Magento Promotional rules.

It's location in file js/mage/adminhtml/rules.js. The method you want to look at is showChooserElement, which is called by initParam, this part to be exact.

var trig = elem.down('.rule-chooser-trigger');
if (trig) {
   Event.observe(trig, 'click', this.toggleChooser.bind(this, container));
}

So calling VarienRulesForm.showChooserElement(element); with the right kind of element (having all the required attributes) should in theory give you the chooser. Still, you'll need to do a lot of tweaking I guess.

Related Topic