Question

I am creating a custom report.

I don't need Period and Empty Rows Option from the report.

How can I remove it?

io

Was it helpful?

Solution

You can able to find the Period and Empty Rows from the below core block file. You can override that core file to custom module and remove that field.

File path: magento/vendor/magento/module-reports/Block/Adminhtml/Filter/Form.php

$fieldset->addField(
            'period_type',
            'select',
            [
                'name' => 'period_type',
                'options' => ['day' => __('Day'), 'month' => __('Month'), 'year' => __('Year')],
                'label' => __('Period'),
                'title' => __('Period')
            ]
        );

$fieldset->addField(
    'show_empty_rows',
    'select',
    [
        'name' => 'show_empty_rows',
        'options' => ['1' => __('Yes'), '0' => __('No')],
        'label' => __('Empty Rows'),
        'title' => __('Empty Rows')
    ]
);

Hope it help.

OTHER TIPS

You can hide the column using layout xml. File path : app/code/Vendor/Module/view/adminhtml/layout/salereport_report_sales_customsalereport.xml

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <update handle="reports_sales"/>
    <body>
        <referenceContainer name="content">
            <block class="Vendor\Module\Block\Adminhtml\Sales\Customsalereport" template="Magento_Reports::report/grid/container.phtml" name="sales.report.grid.container">
                <block class="Magento\Sales\Block\Adminhtml\Report\Filter\Form" name="grid.filter.form">
                    <action method="setFieldVisibility">
                        <argument name="field" xsi:type="string">period_type</argument>
                        <argument name="visibility" xsi:type="string">0</argument>
                    </action>
                    <action method="setFieldVisibility">
                        <argument name="field" xsi:type="string">show_empty_rows</argument>
                        <argument name="visibility" xsi:type="string">0</argument>
                    </action>
                </block>
            </block>
        </referenceContainer>
    </body>
</page>
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top