久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

覆蓋 Magento 配置

Override Magento Config(覆蓋 Magento 配置)
本文介紹了覆蓋 Magento 配置的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我正在尋找一個很好的解決方案來覆蓋 Magento 配置而不更改默認值.

I am looking for a good solution to override the Magento config without changing the default values.

例如,我想在不刪除現有值的情況下覆蓋 core_config_data 表中的web/unsecure/base_skin_url"項.因此,如果代碼中的任何地方都調用了此確切代碼:

For example, I want to override the "web/unsecure/base_skin_url" item in the core_config_data table without deleting the existing value. So if anywhere in the code this exact code is called:

Mage::getStoreConfig('web/unsecure/base_skin_url');

它會找到我設置的配置選項,而不是默認的...

It will find the config option I set and not the default one...

提前致謝!

查克

推薦答案

Magento 在運行時直接從配置對象的樹結構中讀取其配置值,因此需要使用配置對象的原生 setNode 方法更改值.但是,由于 Magento 加載范圍配置(自鏈接)的方式,它并不那么直接向前看.

Magento reads its configuration values at runtime directly from the configuration object's tree structure, so you need to use the configuration object's native setNode method to change the values. However, because of the way Magento loads in scoped configuration (self link), it's not as straight forward as it seems.

使用當前版本的 Magento(我相信,但尚未使用舊版本測試),您需要在當前 store 的節點集中設置配置值.

With current versions of Magento (and I believe, but have not tested, with older versions), you'll need to set the configuration value in the set of nodes for the current store.

第一步是獲取當前設置的商店的代碼.您可以通過以下方式以編程方式執行此操作

Step one is getting the code for the currently set store. You can do this programmatically with the following

$store = Mage::app()->getStore();
$code  = $store->getCode();

然后,您可以通過以下調用設置配置值

then, you can set a configuration value with the following call

$config = Mage::getConfig();
$config->setNode("stores/$code/web/unsecure/base_skin_url", 'value_to_set');

請記住,這一切都需要在 Magento 引導配置對象之后發生.還要記住,有一段時間 Magento 會加載配置,但不會加載 store 對象.如果是這種情況,您將無法從商店對象加載商店代碼.

Keep in mind this all needs to happen after Magento has bootstrapped the configuration object. Also keep in mind there's a period of time where Magento will have a loaded configuration, but the store object will not be loaded. If this is the case you will not be able to load the store code from the store object.

我在我的 Pulse Storm Chaos 模塊中做了類似的事情.如果您對工作代碼感興趣,請訪問 Github.

I did something similar in my Pulse Storm Chaos module. If you're interested in working code it's on Github.

這篇關于覆蓋 Magento 配置的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

What would cause a print_r and/or a var_dump to fail debugging a variable?(什么會導致 print_r 和/或 var_dump 調試變量失敗?)
How to update custom options programatically in magento?(如何在 magento 中以編程方式更新自定義選項?)
Magento 404 on Admin Page(管理頁面上的 Magento 404)
Magento - get price rules from order(Magento - 從訂單中獲取價格規則)
Magento Change Product Page Titles to Include Attributes(Magento 更改產品頁面標題以包含屬性)
Magento: adding duties/taxes to a quote during review(Magento:在審查期間向報價添加關稅/稅款)
主站蜘蛛池模板: 操久久 | 在线观看中文字幕视频 | 欧美国产免费 | 欧美日韩精品区 | 国产一二三视频在线观看 | 欧美成人手机视频 | 欧美色性 | 久久精品国产一区二区电影 | 久久精品成人 | 亚洲综合五月天婷婷 | 国产精品久久亚洲7777 | 久久免费香蕉视频 | 久久国产精品精品 | 亚洲一区二区三区在线视频 | 91精品久久久久久综合五月天 | 天天艹天天干天天 | 国产乱码精品一区二区三区五月婷 | 午夜久久久久 | 精品1区2区 | 99精品久久 | 亚洲精品二区 | 欧美 日韩 在线播放 | 日韩中文字幕 | 日韩一区二区在线视频 | 亚洲精品第一 | 国产福利资源在线 | 97超碰在线播放 | 亚洲一区二区在线 | 午夜三级网站 | 91丨九色丨国产在线 | 亚洲午夜精品视频 | 91久久看片 | 精品视频在线播放 | www.国产一区| 二区国产| 日日夜夜精品视频 | 日韩久久综合 | 久久精品国产久精国产 | 国产国语精品 | 午夜精品久久久 | 国产成人精品一区二 |