2017-07-26 21 views

答えて

1

あなたsystem.xml

<fields> 
    <enable translate="label"> 
     <label>Enable</label> 
     <frontend_type>select</frontend_type> 
     <source_model>adminhtml/system_config_source_yesno</source_model> 
     <sort_order>0</sort_order> 
     <show_in_default>1</show_in_default> 
     <show_in_website>1</show_in_website> 
     <show_in_store>1</show_in_store> 
     <comment>enable/disable the module</comment> 
    </enable> 
</fields> 

にこのコードを追加して、あなたのコードでこれを確認します。モジュールでの最初のアクションの前に

$isenabled = Mage::getStoreConfig('section_name/group_name/enable'); 
if (!$isenabled) { 
    return; 
} 
+0

私がお勧めしたい(これはあなたのcron.php or observer.php or indexcontrollerにあるかもしれません) 'Mage :: getStoreConfigFlag'は' boolean'値を返します。 – sv3n

+0

@ sv3n唯一の違いは、getStoreConfigFlag()はその名前が示すとおり、getStoreConfig()が正確な値を返し、ブール値trueまたはfalseを返します。どちらのメソッドも私たちをMage_Core_Model_Store :: getConfig()に送ります。 – NID

+1

私の知るところでは、正確な値を取得したいすべてのフィールドに 'Mage :: getStoreConfig'を使うべきです。他のすべての場合(yes/noまたはenabled/disabled)、 'if(false)'と完全に等しくないので、 'Mage :: getStoreConfigFlag'を使用します。まだ正解: – sv3n

0

system.xmlの新しい有効化/無効化フィールドをモジュールの前に追加すると、有効な場合はこのフィールド値をチェックし、そうでない場合は実行できます。

0

あなたは

は、たとえばあなたがSystem.Xmlの

<enable translate="label"> 
<label>enable</label> 
<frontend_type>select</frontend_type> 
<source_model>adminhtml/system_config_source_yesno</source_model> 
<sort_order>10</sort_order> 
<show_in_default>1</show_in_default> 
<show_in_website>1</show_in_website> 
<show_in_store>1</show_in_store> 

にそして、あなたのxmlファイル内のフィールドを作り、あなたのxmlファイルにifconfigコマンドを使用する必要が

<block class="your Blockname" name="name of field" ifconfig="sectionname/groupname/enable"> 

あなたのモジュールが有効にすると、それ以外の場合は表示されません。

関連する問題