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

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

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

問題描述

我有以下代碼:

$_productCollection = $this->getLoadedProductCollection();

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

雖然它做了它應(yīng)該做的事情,但它大大減慢了頁(yè)面加載時(shí)間.是否可以僅加載可配置產(chǎn)品并取消對(duì)可配置"的檢查?商店有12000種產(chǎn)品,約700種可配置,其余為兒童簡(jiǎn)單產(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)品.我只需要當(dāng)前類別中的產(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ù)庫(kù)中檢索了產(chǎn)品的數(shù)據(jù).僅使用當(dāng)前類別的產(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ù)庫(kù)連接的資源的所有詳細(xì)信息、緩存值以及產(chǎn)品的個(gè)體資源等等...

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...

在這種情況下,我認(rèn)為您會(huì)更滿意:

In this case I think you would be happier with:

print_r($_productCollection->toArray())

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

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(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 中是否有客戶帳戶注冊(cè)事件?)
Magento addFieldToFilter: Two fields, match as OR, not AND(Magento addFieldToFilter:兩個(gè)字段,匹配為 OR,而不是 AND)
quot;Error 404 Not Foundquot; in Magento Admin Login Page(“未找到錯(cuò)誤 404在 Magento 管理員登錄頁(yè)面)
Get Order Increment Id in Magento(在 Magento 中獲取訂單增量 ID)
主站蜘蛛池模板: 中文字幕精品一区 | 一区二区三区四区av | 国产一区二区视频免费在线观看 | 亚洲福利一区二区 | 久热久热| 亚洲一区二区三区四区五区午夜 | 在线免费看毛片 | 91av免费看 | 日韩欧美亚洲 | 精品国产免费人成在线观看 | 日本黄视频在线观看 | 视频一二三区 | 99国内精品久久久久久久 | 欧美成人影院在线 | 成人小视频在线观看 | 国产一区二区三区四区五区加勒比 | 九九精品在线 | 久久成 | 亚洲天堂中文字幕 | 日本特黄特色aaa大片免费 | 国产精品亚洲成在人线 | 国产一区二区三区 | 精品国产99 | 久久久久久久久久久久久9999 | com.国产| 国产精品中文在线 | 国产美女黄色 | 欧美在线一区二区三区 | 草久久久 | 久久久久国产一区二区三区 | 亚洲一区二区三区视频免费观看 | 亚洲精品视频在线播放 | 国产欧美精品区一区二区三区 | 天堂免费 | 9999久久 | 九九热这里只有精品在线观看 | 久久久久久久久久影视 | 九九在线视频 | 成人黄色电影免费 | 亚洲av一级毛片 | 国产日韩久久 |