Ian Gallimore
Ian Gallimore

Reputation: 95

Mimic the Magento 'select product' functionality - as seen in the widget

Has anyone successfully managed to copy the 'select product' functionality from one of the standard widgets and use it in their own custom (admin) module?

I have a custom module (with an admin interface) that I'd like to improve slightly by allowing the administrator to select an existing product from the catalog using the same functionality that I've seen in the catalog-product-select widget. I.e my adminstrator should click on a button and that would launch an ajax layer (popup?) with the tree and grid UI.

Having attempted to reverse engineer this functionality, I can see that the widget is using the Mage_Adminhtml_Block_Catalog_Product_Widget_Chooser.php file.

Although ideally I'd very much appreciate any info / links on this, if no-one knows how to do this, then can anyone show me some code to do the first step - to launch a php file within an ajax layer popup.

Thanks in advance, Ian

Upvotes: 1

Views: 1084

Answers (1)

Daniel Schönherr
Daniel Schönherr

Reputation: 235

following code will do this:

<choose_product>
    <label>Choose Product</label>
    <visible>1</visible>
    <required>1</required>
    <type>label</type>
    <helper_block>
        <type>adminhtml/catalog_product_widget_chooser</type>
        <data>
            <button translate="open">
                <open>Select Product...</open>
            </button>
        </data>
    </helper_block>
</choose_product>

just add that to your "parameters"-Section inside your widget.xml

Upvotes: 3

Related Questions