Import button + File browse field in admin product grid in magento

Import button + File browse field in admin product grid in magento

August 21, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Import button + File browse field in admin product grid in magento

Adding an Import Button and File Browse Field to Magento Admin Product Grid

In this post, we’ll guide you through adding an “Import” button and a file browse field next to the “Add Product” button on the product grid page in your Magento admin panel.

Why Add Import Functionality?

Adding direct import functionality from the product grid allows administrators to easily bring in new products or update existing ones without navigating away from the main grid view. This streamlines workflows and saves time for your team.

Step 1: Create the Import Button and File Browse Field

To add a file browse field, you’ll need to modify the catalog_product_grid.xml layout file located under:

app/code/Magento/Catalog/view/adminhtml/layout

Find the existing <reference name="content"> block and add the following lines inside it:

<referenceContainer name="grid.toolbar">
    <block class="Magento\Backend\Block\Widget\Button" as="import_products_button">
        <arguments>
            <argument name="label" translate="true" xsi:type="string">Import Products</argument>
            <argument name="on_click" xsi:type="string">window.open('<?php echo $this->getUrl("catalog/product/import") ?>', '_blank')</argument>
        </arguments>
    </block>

    <container name="grid.additional.toolbar">
        <block class="Magento\Backend\Block\Widget\Container"
               as="product_import_form"
               before="-">
            <block class="Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Import"
                   template="Magento_Catalog::product/import.phtml"
                   name="catalog_product_import" />
        </block>
    </container>
</referenceContainer>

This code adds a new “Import Products” button and places it inside the existing toolbar. It also defines a new container for the file browse form.

Step 2: Create the Import Profile

To handle the upload, you’ll need to create an import profile in the catalog_product_import module under:

app/code/Magento/Catalog/etc/import

Create a new XML file (e.g., test_import.xml) that defines your import behavior. For detailed instructions on creating profiles, refer to the official Magento documentation.

Step 3: Modify Product Import Script

Finally, you need to modify the product import script located at:

app/code/Magento/Catalog/Controller/Adminhtml/Product/Import.php

In the execute() method, after processing the import file, add code to open a new tab and run your custom profile, like so:

$importProfile = 'test_import';
$importResult = $this->batchImport->run($fileName, $importProfile);

if ($importResult) {
    $importUrl = $this->getUrl('catalog/product/export');
    Javascript::set(array(
        'window.open(\'' . $importUrl . '\', \'_blank\')'
    ));
}

Conclusion

Adding an Import button and file browse field to the Magento admin product grid page allows for faster data management within your e-commerce platform. By following this guide, you’ve learned how to:

  1. Modify layout files to add a new button and form.
  2. Create an import profile to handle uploaded files.
  3. Modify the import script to open a new tab after processing.

Remember to always test these changes in a development environment first before applying them to your live site. If you encounter any issues or need further assistance, feel free to reach out to our Magento support team for expert help.

Happy coding!

Catalog Themes Admin Import/Export

Our network