Webサイト、ストア、およびデフォルトのスコープにシステム設定データを取得する

magento.stackexchange https://magento.stackexchange.com//questions/51954

質問

System-> Configuration-> Designでカスタムグループとフィールドを作成しました 以下のイベントを使用しました。

<admin_system_config_changed_section_design>
    <observers>
        <custom>
            <type>singleton</type>
            <class>Custon_Custom_Observer</class>
            <method>save</method>
            </custom>
    </observers>
</admin_system_config_changed_section_design>
.

マゼントには3種類のスコープがあります。

1)デフォルト

2)Webサイト

3)

私のカスタムフィールドのすべての値は、カスタムテーブルに値を格納するようにします。 ENTER IMENTDESCRUシストの入力 たとえば、 記述フィールド値を保存します。

Mage::getStoreConfig('design/custom/description');
.

上記の値をWebサイトレベルと現在のストアレベルにしたいです。 私はこのリンク

役に立ちましたか?

解決

config.xml、

 <global>
    <events>
        <admin_system_config_changed_section_design>
            <observers>
                <custom>
                    <type>singleton</type>
                    <class>Custon_Custom_Observer</class>
                    <method>saveSystemConfig</method>
                    </custom>
            </observers>
        </admin_system_config_changed_section_design>
    </events>
 </global>
.

Observer.php、

public function saveSystemConfig(Varien_Event_Observer $observer)
{
    $postData = $observer->getEvent()->getData();

    if (is_null($postData['store']) && $postData['website']) //check for website scope
    {
        $scopeId = Mage::getModel('core/website')->load($postData['website'])->getId();
        $description  = Mage::app()->getWebsite($scopeId)->getConfig('design/custom/description');
        $currentScope = 'websites';
    }
    elseif($postData['store']) //check for store scope
    {
        $scopeId =   Mage::getModel('core/store')->load($postData['store'])->getId();
        $description  = Mage::app()->getStore($scopeId)->getConfig('design/custom/description');
        $currentScope = 'stores';
    }
    else //for default scope
    {
        $scopeId = 0;
        $description  = Mage::getStoreConfig('design/social-meta-tags/design/custom/description')
        $currentScope = 'default';
    }
}
.

上記から、すべてのスコープで個別のフィールド値を取得できます。

ライセンス: CC-BY-SA帰属
所属していません magento.stackexchange
scroll top