Magento 2-使用\ Magento \ Catalog \ Block \ Adminhtml \ Product \ Widget \ Chooser有多个选择吗?


14

使用此代码

$chooser = $this->_layout->createBlock('\Magento\Catalog\Block\Adminhtml\Product\Widget\Chooser');
        var_dump(get_class_methods($chooser));

        $configChooser = [
            'button' => [
                'open' => __('Select Products'),
                'type' => '\Magento\Catalog\Block\Adminhtml\Product\Widget\Chooser',
            ]
        ];
        $chooser->setConfig($configChooser)
            ->setFieldsetId($fieldsetData->getId())
        ->prepareElementHtml($productChooser);

我可以在我的自定义表单中为我的自定义字段获得一个非常不错的产品选择器,但是我需要它能够选择多个产品。我可以设置选择器配置吗?


2
嗨,詹妮,您能否以自定义模块形式共享更多有关“产品选择器”的代码。我想弄清楚,但我做不到。谢谢。
hayatbiralem

Answers:


1
 <fieldset name="assign_products" sortOrder="40">
            <settings>
                <collapsible>true</collapsible>
            <label translate="true">Products</label>
            </settings>
                <container name="assign_products_container" sortOrder="160">
                 <htmlContent name="html_content">
                     <block name="my_assigned_products" class="Magento\Catalog\Block\Adminhtml\Product\Grid">
                     <arguments>
                            <argument name="button" xsi:type="array">
                             <item name="open" xsi:type="string" translate="true">Select Product...</item>
                            </argument>
                     </arguments>
                     </block>
            </htmlContent>
            </container>
</fieldset>

非常感谢我在自定义ui表单上完成的工作。
user77175 '19

0
<fieldset name="assign_products" sortOrder="40">

真正的产品选择产品...


使用Magento \ Catalog \ Block \ Adminhtml \ Product \ Grid而不是Magento \ Catalog \ Block \ Adminhtml \ Product \ Widget \ Chooser

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.