-
-
Save tieutantan/7b53fe6dc4d3c02fb80c9c73b0ef0498 to your computer and use it in GitHub Desktop.
Magento2 : Add Custom Store Configuration exposed to graphQL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- etc/graphql/di.xml --> | |
<?xml version="1.0"?> | |
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> | |
<type name="Magento\StoreGraphQl\Model\Resolver\Store\StoreConfigDataProvider"> | |
<arguments> | |
<argument name="extendedConfigData" xsi:type="array"> | |
<item name="custom_config" xsi:type="string">mynamespace_mymodule/general/custom_config</item> | |
</argument> | |
</arguments> | |
</type> | |
</config> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# etc/schema.graphqls | |
type StoreConfig { | |
custom_config : Boolean @doc(description: "Custom Config") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- etc/adminhtml/system.xml --> | |
<?xml version="1.0" encoding="UTF-8" ?> | |
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd"> | |
<system> | |
<tab id="customtab" translate="label" sortOrder="100"> | |
<label>Custom Tab</label> | |
</tab> | |
<section id="mynamespace_mymodule" translate="label" sortOrder="100" showInDefault="1" showInWebsite="1" showInStore="1"> | |
<tab>customtab</tab> | |
<label>Section Label</label> | |
<resource>MyNamespace_MyModule::mymodule</resource> | |
<group id="general" showInDefault="1" showInWebsite="1" showInStore="1" sortOrder="100"> | |
<label>General</label> | |
<field id="custom_config" type="select" showInDefault="1" showInWebsite="1" showInStore="1" sortOrder="100"> | |
<label>My Custom Config</label> | |
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model> | |
</field> | |
</group> | |
</section> | |
</system> | |
</config> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment