0

How to show only bundle products on custom module admin grid (not in admin form tabs) in magento 2.Can you please anyone help me in this.

2 Answers 2

0

Try to enable it from admin Catalog/Manage Attributes

1
  • 1
    Actually i want to show only bundle products in my custom module admin grid in magento 2 not in magento 1.x Oct 24, 2016 at 11:56
0

Step to show list of products in admin UI grid:

1) set ui component xml in layout xml file like this :

<body>
    <referenceContainer name="content">
        <uiComponent name="items_items_listing"/>
    </referenceContainer>
</body>

2) Create ui component file inside ui_component folder

3) set provider dependency in di.xml :

<type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
    <arguments>
        <argument name="collections" xsi:type="array">
            <item name="brand_grid_data_source" xsi:type="string">vendor_name\module_name\Model\ResourceModel\Model_name\Grid\Collection</item>
        </argument>
    </arguments>
</type>
<type name="vendor_name\module_name\Model\ResourceModel\Model_name\Grid\Collection">
    <arguments>
        <argument name="mainTable" xsi:type="string">table_name</argument>
        <argument name="eventPrefix" xsi:type="string">vendor_name_module_name_grid_collection</argument>
        <argument name="eventObject" xsi:type="string">vendor_name_module_name_grid_collection</argument>
        <argument name="resourceModel" xsi:type="string">Vendor_name\Module_name\Model\ResourceModel\Model_name</argument>
    </arguments>
</type>
<virtualType name="BrandGridDataProvider" type="Magento\Framework\View\Element\UiComponent\DataProvider\DataProvider">
    <arguments>
        <argument name="collection" xsi:type="object" shared="false">vendor_name\module_name\Model\ResourceModel\Model_name\Collection</argument>
        <argument name="filterPool" xsi:type="object" shared="false">BrandGrrdFilterPool</argument>
    </arguments>
</virtualType>
<virtualType name="BrandGrrdFilterPool" type="Magento\Framework\View\Element\UiComponent\DataProvider\FilterPool">
    <arguments>
        <argument name="appliers" xsi:type="array">
            <item name="regular" xsi:type="object">Magento\Framework\View\Element\UiComponent\DataProvider\RegularFilter</item>
            <item name="fulltext" xsi:type="object">Magento\Framework\View\Element\UiComponent\DataProvider\FulltextFilter</item>
        </argument>
    </arguments>
</virtualType>
3
  • model has your collection data which directly set into your provider Oct 24, 2016 at 13:12
  • yes but we are not using any particular table here na.The product data comes from various tables how we can give one table name here.I have a product collection in block file one function Oct 24, 2016 at 14:16
  • protected function _prepareCollection() { $collection = $this->productFactory->create()->getCollection()->addAttributeToSelect("*")->addAttributeToFilter('sku', 'example'); $this->setCollection($collection); return parent::_prepareCollection(); } Oct 24, 2016 at 14:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.