---
title: "Magento 2: How to Add Sample CSV Download Option in System Configuration"
url: "https://magecomp.com/blog/magento-2-add-sample-csv-download-option-in-system-configuration/"
date: "2024-05-31T15:36:59+00:00"
modified: "2024-05-31T15:36:59+00:00"
author:
  name: "Dhiren Vasoya"
  url: "https://magecomp.com/"
categories:
  - "How To"
  - "Magento 2"
word_count: 457
reading_time: "3 min read"
summary: "Hello Magento Friends,"
description: "Learn how to add a sample CSV download option in Magento 2 system configuration with this comprehensive step-by-step guide."
keywords: "How To, Magento 2"
language: "en"
schema_type: "Article"
related_posts:
  - title: "Magento 2: Add Track Order link with the Order on Order History Page"
    url: "https://magecomp.com/blog/magento-2-add-track-order-link-on-order-history-page/"
  - title: "How to Get All Regions/States of Specific Country by Country Code in Magento 2?"
    url: "https://magecomp.com/blog/get-all-regions-states-of-specific-country-by-country-code-magento-2/"
  - title: "Magento 2: How to Add Custom Mass Action in Product Grid"
    url: "https://magecomp.com/blog/magento-2-add-custom-mass-action-in-product-grid/"
---

# Magento 2: How to Add Sample CSV Download Option in System Configuration

_Published: May 31, 2024_  
_Author: Dhiren Vasoya_  

![](https://magecomp.com/blog/wp-content/uploads/2024/05/Magento-2-How-to-Add-Sample-CSV-Download-Option-in-System-Configuration-1-1024x512.webp)

**Hello Magento Friends,**

In Magento 2, providing sample data files can be extremely useful for users, especially when dealing with bulk uploads or configurations that require a specific format. Adding a sample CSV download option in the system configuration is a great way to guide users. It provides a template file with the correct format and headers, streamlining data import for products, customers, or other entities.
This tutorial will walk you through the steps for Adding Sample CSV Download Option in the Magento 2 System Configuration.
## Steps to Add Sample CSV Download Option in Magento 2 System Configuration:
**Step 1:** Create the **system.xml** file inside Extension etc folder.
**app\code\Vendor\Extension\etc\adminhtml**

Then add the code as follows
```
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
    <system>
                	<group id="yourgroupid" translate="label" sortOrder="120" showInDefault="1" showInWebsite="1"
                       showInStore="1">
                    <field id="download_sample_file" translate="label" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="1">
                         <label>Sample File</label>
                        <frontend_model>VendorExtensionBlockAdminhtmlSystemConfigButton</frontend_model>
                    </field>
                </group>
            </system>
</config>
```

**Step 2:** Now, create the **Button.php** file inside the Extension Block folder.
**app\code\Vendor\Extension\Block\Adminhtml\System\Config**

And add the below-mentioned code
```
<?php
namespace VendorExtensionBlockAdminhtmlSystemConfig;

use MagentoConfigBlockSystemConfigFormField;
use MagentoFrameworkDataFormElementAbstractElement;
use MagentoFrameworkViewAssetRepository;
use MagentoBackendBlockTemplateContext;

class Button extends Field
{
    protected $_assetRepo;
    public function __construct(
        Repository $assetRepo,
        Context $context,
        array $data = []
    ) {
        $this->_assetRepo = $assetRepo;
        parent::__construct($context, $data);
    }
    /**
     * Get the button Run
     *
     * @param AbstractElement $element
     * @return string
     */
    protected function _getElementHtml(AbstractElement $element)
    {
        $url = $this->_assetRepo->getUrl("Vendor_Extension::csv/sample.csv");
        return '<a download="sample.csv" href="&#039; . $url . &#039;" style="cursor:pointer;" data-wpel-link="internal" target="_blank" rel="follow">' . __('Download Sample Csv File') . '</a>';
    }
}
```

**Step 3:** Now, you need to add the **sample.csv** file inside the below path.

**app\code\Vendor\Extension\view\adminhtml\web\csv**

**Output:**

You have now successfully added a sample CSV download option in the Magento 2 system configuration.
![download sample csv option](https://magecomp.com/blog/wp-content/uploads/2024/05/download-sample-csv-option.png)

## Conclusion:
You have successfully added a sample CSV download option in the Magento 2 system configuration. This feature will help users understand the required format for CSV files, reducing errors and improving user experience.
If you have any doubts, let me know through the comment section. Share the tutorial with your friends and stay updated with us.
For any customization requirement, [**Hire an Experienced Magento Developer**](https://magecomp.com/hire-magento-developer.html).
**Happy Coding!**


---

_View the original post at: [https://magecomp.com/blog/magento-2-add-sample-csv-download-option-in-system-configuration/](https://magecomp.com/blog/magento-2-add-sample-csv-download-option-in-system-configuration/)_  
_Served as markdown by [Third Audience](https://github.com/third-audience) v3.5.3_  
_Generated: 2026-08-24 14:34:20 UTC_  
