Magento 2: Change per page option for customer, Order & product Admin Grid

As a default, Magento Admin has Paging option as 20, 30, 50,100,200 But I need to change it for Product, Customer & Order Grid.

I override the below files:

vendor/magento/module-customer/view/adminhtml/ui_component/customer_listing.xml
vendor/magento/module-sales/view/adminhtml/ui_component/sales_order_grid.xml
vendor/magento/module-catalog/view/adminhtml/ui_component/product_listing.xml

And Changed content inside tag:

From:

<paging name="listing_paging">
        <argument name="data" xsi:type="array">
            <item name="config" xsi:type="array">
                <item name="storageConfig" xsi:type="array">
                    <item name="provider" xsi:type="string">sales_order_grid.sales_order_grid.listing_top.bookmarks</item>
                    <item name="namespace" xsi:type="string">current.paging</item>
                </item>
                <item name="selectProvider" xsi:type="string">sales_order_grid.sales_order_grid.sales_order_columns.ids</item>
            </item>
        </argument>
    </paging>

To:

<paging name="listing_paging">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="storageConfig" xsi:type="array">
                        <item name="provider" xsi:type="string">customer_listing.customer_listing.listing_top.bookmarks</item>
                        <item name="namespace" xsi:type="string">current.paging</item>
                    </item>
                    <item name="selectProvider" xsi:type="string">customer_listing.customer_listing.customer_columns.ids</item>

                    <item name="sizesConfig" xsi:type="array">
                        <item name="value" xsi:type="string">25</item>
                        <item name="minSize" xsi:type="string">1</item>
                        <item name="maxSize" xsi:type="string">100</item>
                        <item name="options" xsi:type="array">
                            <item name="25" xsi:type="array">
                                <item name="value" xsi:type="string">25</item>
                                <item name="label" xsi:type="string">25</item>
                            </item>
                            <item name="30" xsi:type="array">
                                <item name="value" xsi:type="string">30</item>
                                <item name="label" xsi:type="string">30</item>
                            </item>
                            <item name="50" xsi:type="array">
                                <item name="value" xsi:type="string">50</item>
                                <item name="label" xsi:type="string">50</item>
                            </item>
                            <item name="100" xsi:type="array">
                                <item name="value" xsi:type="string">100</item>
                                <item name="label" xsi:type="string">100</item>
                            </item>
                        </item>
                    </item>                          
                </item>
            </argument>
        </paging>

But it’s not helpful. What am I doing wrong here?

Here is Solutions:

We have many solutions to this problem, But we recommend you to use the first solution because it is tested & true solution that will 100% work for you.

Solution 1

So finally I ended up with below solution. Check it out if you have same requirement:

Below are two main files paging option comes:

vendor/magento/module-ui/view/base/web/js/grid/paging/sizes.js
vendor/magento/module-ui/view/base/web/templates/grid/paging/sizes.html

Override in your theme. Now to change option in per page dropdown change below code as per your requirement:

        options: {
            '20': {
                value: 20,
                label: 20
            },
            '30': {
                value: 30,
                label: 30
            },
            '50': {
                value: 50,
                label: 50
            },
            '100': {
                value: 100,
                label: 100
            },
            '200': {
                value: 200,
                label: 200
            }
        },

Now do static content deploy php bin/magento s:s:d

Note: This will make changes for all Admin Grids.

Note: Use and implement solution 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply