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

Magento - 只加載可配置的產品

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

問題描述

我有以下代碼:

$_productCollection = $this->getLoadedProductCollection();

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

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

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.

我發現以下代碼返回所有可配置的產品.我只需要當前類別中的產品:

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() 的問題是它已經加載了 - 已經從數據庫中檢索了產品的數據.僅使用當前類別的產品集合也不夠好,這將忽略層"(屬性過濾器).訣竅是首先從列表中刪除加載的產品.

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) 也有問題,您不僅要輸出產品,還要輸出作為數據庫連接的資源的所有詳細信息、緩存值以及產品的個體資源等等...

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())

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

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

相關文檔推薦

Magento products by categories(按類別劃分的 Magento 產品)
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在线播放 | 久草免费在线视频 | 亚洲精品成人av久久 | 在线免费国产视频 | 欧美一级免费看 | 91在线第一页 | 亚洲一区二区三区久久久 | 国产高清av免费观看 | 久久久精品综合 | 久久av资源网 | 婷婷久久综合 | 麻豆av一区二区三区久久 | 五月婷婷激情网 | 精品乱子伦一区二区三区 | 久久综合影院 | 成年免费视频 | 国产一区 | 久久久不卡网国产精品一区 | 国产一级一级毛片 | 日韩久草 | 免费看国产精品视频 | 欧美二区在线 | 国产二区在线播放 | 中文字幕 在线观看 | 国产午夜精品一区二区三区嫩草 | 国产精品99久久久久久久久久久久 | 久久精品亚洲一区二区三区浴池 | 欧美理论在线观看 | 成人小视频在线观看 | 亚洲精品视频免费观看 | 亚洲欧美日韩精品久久亚洲区 | 一区二区三区四区在线视频 | 亚洲www啪成人一区二区麻豆 | 国产精品毛片一区二区在线看 | 精品一区二区av |