久久久久久久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:在審查期間向報價添加關稅/稅款)
主站蜘蛛池模板: 欧美性生交大片免费 | 天天干天天谢 | 欧美久久一级特黄毛片 | 中文字字幕一区二区三区四区五区 | 久久久久久99 | 国产高清在线精品一区二区三区 | 999免费网站 | 精品毛片 | 国产精品成av人在线视午夜片 | 国产精品视频入口 | 国产日韩一区二区三区 | 久操国产| 久久不卡| 国产精品久久777777 | 91精品入口蜜桃 | 日韩男人天堂 | 国产精品久久一区二区三区 | 精品美女| 成人一区二区三区在线 | 在线午夜 | 91av视频在线 | 999久久 | 亚洲在线一区 | 亚洲精久久久 | 国产乱码精品1区2区3区 | 欧美精品在线免费观看 | 精品一区二区在线观看 | 伊人欧美视频 | av一区二区三区 | 激情一区二区三区 | av网站在线看| 国产视频第一页 | 亚洲福利在线视频 | 黄色av免费| 免费高潮视频95在线观看网站 | 在线成人免费视频 | 久久午夜剧场 | 91欧美| 欧美一级做性受免费大片免费 | 亚洲一区二区三区久久 | 欧美日韩一区二区三区四区 |