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

Magento:Mage::registry('current_product') 有效嗎?

Magento: Mage::registry(#39;current_product#39;) efficient?(Magento:Mage::registry(current_product) 有效嗎?)
本文介紹了Magento:Mage::registry('current_product') 有效嗎?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

如果您了解其背后的過程,這可能是顯而易見的.但是,例如,當您在產品頁面上使用 Mage::registry('current_product') 時,您是否只是在引用某些內容已經加載"了還是每次運行該行代碼時都加載它?

This is probably something obvious if you know the process behind it.. But when you use Mage::registry('current_product') on a product page, for example, are you merely referencing something that is already "loaded" or are you loading it every time you run that line of code?

換句話說,哪個更有效率?(下面是偽代碼)

In other words, which is more efficient? (pseudocode below)

Mage::registry('current_product')->getName() over and over

或者...

$temp = Mage::registry('current_product') then
$temp->getName() over and over

推薦答案

調用

Mage::registry('current_product')->getName()

一遍又一遍地稍微

$temp = Mage::registry('current_product') then
$temp->getName() over and over

但這并沒有那么糟糕,我會非常擔心.如果您要設置編碼風格,請選擇第二種.如果你有一堆舊代碼和前者,不要擔心它的性能.

But it's not so bad that I'd be super concerned about. If you're setting a coding style, pick the second. If you have a bunch of old code with the former, don't worry about its performance.

當您調用 Mage::registry('current_product') 時,產品本身不會從數據庫中重新加載 — 此方法所做的只是返回一個存儲在靜態數組中的對象引用Mage 類的.

The product itself won't be reloaded from the database when you call Mage::registry('current_product') —?all this method does is return an object reference that's been stored on a static array of the Mage class.

我說前者效率稍低的原因是,如果你看一下registry

The reason I say the former will be slightly less efficient is, if you take a look at the source of registry

#File: app/Mage.php
public static function registry($key)
{
    if (isset(self::$_registry[$key])) {
        return self::$_registry[$key];
    }
    return null;
}

您將看到 Magento 在返回值之前檢查鍵是否已設置.從理論上講,這項檢查比從 registry 中抓取一次然后重用變量更多的工作.

You'll see Magento check if the key is set before returning a value. This check, theoretically, is more work that grabbing it from registry once and then reusing the variable.

但是,實際上,在這成為真正的問題之前,您將遇到更大的瓶頸.

However, practically speaking, you're going to have bigger bottlenecks before this is a real problem.

這篇關于Magento:Mage::registry('current_product') 有效嗎?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

相關文檔推薦

Joining 2 tables in SELECT(MYSQL/PHP)(在 SELECT(MYSQL/PHP) 中加入 2 個表)
How to make lt;option selected=quot;selectedquot;gt; set by MySQL and PHP?(如何使lt;option selected=“selectedgt;由 MySQL 和 PHP 設置?)
Auto populate a select box using an array in PHP(使用 PHP 中的數組自動填充選擇框)
PHP SQL SELECT where like search item with multiple words(PHP SQL SELECT where like search item with multiple words)
json_encode produce JSON_ERROR_UTF8 from MSSQL-SELECT(json_encode 從 MSSQL-SELECT 產生 JSON_ERROR_UTF8)
MySQL ORDER BY rand(), name ASC(MySQL ORDER BY rand(),名稱 ASC)
主站蜘蛛池模板: 久久综合九九 | 五月婷婷视频 | 91正在播放| 中文日韩在线 | 成人在线小视频 | 婷婷综合五月天 | 不卡在线视频 | 最新国产视频 | 日本一本视频 | dy天堂| 天天干狠狠操 | 超碰在线影院 | 中文字幕在线播放第一页 | 亚洲精品www | 成人精品一区二区三区四区 | 自拍视频精品 | 在线观看日本高清二区 | 丝袜美腿一区二区三区动态图 | 成人a在线 | 永久免费在线观看 | 国产线视频精品免费观看视频 | 欧美伊人久久久久久久久影院 | 婷婷成人在线 | 成人在线观看网站 | 天天综合成人网 | 国产成人aⅴ | 一区二区三区在线观看视频 | 亚洲欧美一区二区三区视频 | 中文字幕一区二区三区四区五区 | 亚洲精品久久久久久国产精华液 | 欧美综合精品 | 成人欧美一区二区三区黑人孕妇 | 日韩精品在线看 | 爱爱视频在线观看 | 国产精品夜间视频香蕉 | 精品国产99 | 亚洲国产欧美一区二区三区久久 | 日韩精品一区二区久久 | 欧美一区二区三区国产 | 精品一区二区三区四区 | 日韩一区二区视频 |