I have a module which shows value in the frontend, and from admin system configuration I want to disable that module options are coming like yes/no no I want to get that value of enabling/ disable module in magento2 enter image description here

as you can see in the picture that options are coming now I want to enable/disable module through these options reference:https://www.mageplaza.com/magento-2-module-development/create-system-xml-configuration-magento-2.html

  • in phtml file you want to get ? Mar 30, 2019 at 6:30
  • yes in frontend options are coming from phtml file and i dont know how to get that value Mar 30, 2019 at 6:35
  • what is your goal on this? please clarify things so that others can help you better
    – fmsthird
    Mar 30, 2019 at 6:51

1 Answer 1


you can create Helper file (Data.php) at this location Mageplaza/HelloWorld/Helper/Data.php.

namespace Mageplaza\HelloWorld\Helper;

use Magento\Framework\App\Helper\AbstractHelper;
use Magento\Framework\App\Helper\Context;
use Magento\Store\Model\ScopeInterface;

class Data extends AbstractHelper
    protected $context;

    public function __construct(Context $context)
        $this->context = $context;

    public function isEnable()
        return $this->scopeConfig->getValue('helloWorld/general/enable', ScopeInterface::SCOPE_STORE);

Now Write this code in phtml file :

$helper = \Magento\Framework\App\ObjectManager::getInstance()->get('Mageplaza\HelloWorld\Helper\Data'); 
if($helper->isEnable()) : ?>


<?php endif; ?>

if you want to created field in value set then below file create
etc/config.xml in your extension

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
                <price>100</price> <!-- here price is field name-->
                ---------<!--other fields-->

  • what is phtml file is for Mar 30, 2019 at 6:41
  • Where you want to this file Mar 30, 2019 at 6:42
  • i want to set the values in textbox like in front there are custom atrributes i want to set that price from backend there is textbox to enter the price Mar 30, 2019 at 6:44
  • 1
    I don’t understand what you want here firstly you want only value of enable disble field Mar 30, 2019 at 6:46
  • You want to price add? Mar 30, 2019 at 6:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.