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

Magento - 只加載可配置的產(chǎn)品

Magento - load only configurable products(Magento - 只加載可配置的產(chǎn)品)
本文介紹了Magento - 只加載可配置的產(chǎn)品的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我有以下代碼:

$_productCollection = $this->getLoadedProductCollection();

foreach ($_productCollection as $_product)
{
  if ($_product->_data['type_id'] == 'configurable')
  {
    ...
  } 
}

雖然它做了它應(yīng)該做的事情,但它大大減慢了頁面加載時間.是否可以僅加載可配置產(chǎn)品并取消對可配置"的檢查?商店有12000種產(chǎn)品,約700種可配置,其余為兒童簡單產(chǎn)品.

While it does what it's supposed to do, it greatly slows down page load time. Is it possible to load only configurable products and remove the check for 'configurable'? The store has 12000 products, about 700 are configurable and the rest are child simple products.

我發(fā)現(xiàn)以下代碼返回所有可配置的產(chǎn)品.我只需要當前類別中的產(chǎn)品:

I found the following code which returns all configurable products. I need only the products within the current category:

$collectionConfigurable = Mage::getResourceModel('catalog/product_collection')
                ->addAttributeToFilter('type_id', array('eq' => 'configurable'));

推薦答案

getLoadedProductCollection() 的問題是它已經(jīng)加載了 - 已經(jīng)從數(shù)據(jù)庫中檢索了產(chǎn)品的數(shù)據(jù).僅使用當前類別的產(chǎn)品集合也不夠好,這將忽略層"(屬性過濾器).訣竅是首先從列表中刪除加載的產(chǎn)品.

The problem with getLoadedProductCollection() is it's already loaded - the products' data has already been retrieved from the database. Just using the current category's product collection isn't good enough either, that will ignore the "layers" (attribute filters). The trick is to remove the loaded products from the list first.

// First make a copy, otherwise the rest of the page might be affected!
$_productCollection = clone $this->getLoadedProductCollection();
// Unset the current products and filter before loading the next.
$_productCollection->clear()
                   ->addAttributeToFilter('type_id', 'configurable')
                   ->load();

print_r($_productCollection) 也有問題,您不僅要輸出產(chǎn)品,還要輸出作為數(shù)據(jù)庫連接的資源的所有詳細信息、緩存值以及產(chǎn)品的個體資源等等...

print_r($_productCollection) has it's issues too, you're not just outputting the products but also all details of the resource that is the database connection, and cached values, and the products' individual resources, and so on...

在這種情況下,我認為您會更滿意:

In this case I think you would be happier with:

print_r($_productCollection->toArray())

這篇關(guān)于Magento - 只加載可配置的產(chǎn)品的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

相關(guān)文檔推薦

Magento products by categories(按類別劃分的 Magento 產(chǎn)品)
Resource interpreted as image but transferred with MIME type text/html - Magento(資源被解釋為圖像但使用 MIME 類型 text/html 傳輸 - Magento)
Is there an event for customer account registration in Magento?(Magento 中是否有客戶帳戶注冊事件?)
Magento addFieldToFilter: Two fields, match as OR, not AND(Magento addFieldToFilter:兩個字段,匹配為 OR,而不是 AND)
quot;Error 404 Not Foundquot; in Magento Admin Login Page(“未找到錯誤 404在 Magento 管理員登錄頁面)
Get Order Increment Id in Magento(在 Magento 中獲取訂單增量 ID)
主站蜘蛛池模板: 精品视频在线免费观看 | 九九热精品在线 | 欧美成人免费在线视频 | 伊人网91 | 免费在线观看av网址 | 97视频在线观看免费 | 亚洲精品电影网在线观看 | 亚洲欧美精品 | 亚洲巨乳自拍在线视频 | 欧美一级电影免费 | 麻豆久久久9性大片 | 男女免费视频网站 | 狠狠的操 | 超碰97免费在线 | 亚洲少妇综合网 | 日韩午夜影院 | 国产激情视频在线观看 | 亚洲超碰在线观看 | 激情五月婷婷 | 国产日本精品视频 | 国产精品美女一区二区三区 | 91精品国产一区 | 久久国产精品精品国产色婷婷 | 国产欧美精品一区 | 久久久999免费视频 999久久久久久久久6666 | 一二三四在线视频观看社区 | 成人在线看片 | 久久久成人一区二区免费影院 | 三级成人在线 | 成人精品免费视频 | 欧美一区免费 | 久草新在线 | 一区二区三区在线免费观看 | 伊人精品在线视频 | 欧美 中文字幕 | 成人av免费在线观看 | 色综合色综合色综合 | 精品人伦一区二区三区蜜桃网站 | 在线一区二区三区 | 午夜小视频在线播放 | 精品久久精品 |