Im trying to add a file_upload to my custom module system configuration.

The backend part works flawlessly and im able to upload the files to the directory i want them to. But i cant read the file where i want to use it, because if i try to get the configuration value, i only get the part of the path after the actual upload directory.

My system.xml looks like this

<?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">
        <tab id="id" translate="label" sortOrder="1000">
        <section id="id" translate="label" type="text" sortOrder="301" showInDefault="1" showInWebsite="0" showInStore="1">
            <group id="id" translate="label" type="text" sortOrder="6" showInDefault="1" showInWebsite="0" showInStore="1">
                <field id="data_type_map" translate="label" type="Magento\Config\Block\System\Config\Form\Field\File" sortOrder="1" showInDefault="1" showInWebsite="0" showInStore="1">
                    <upload_dir scope_info="1">import/catalog/product/config</upload_dir>

So when i request the config value with

$this->scopeConfig->getValue(self::XML_PATH_DATA_TYPE_MAP, $scopeType, $scopeCode);

I get something like "default/foo.csv" but what i want is import/catalog/product/config/default/foo.csv

Is there a way to get the value like this or to read the upload_dir from the configuration without using it as a static string?

  • Did u get the answer for this issue? Please guide me if so. Apr 1 '19 at 13:24
  • No i didnt, the only way i found was using a static path for the time beeing.
    – astragt
    Apr 2 '19 at 7:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.