簡體   English   中英

當產品列表頁上的limit = all時,Magento產品計數錯誤

[英]Magento incorrect product count when limit=all on product list page

在將1.4版之前的Magento網站升級到1.4.1.2版的過程中,我遇到了一個問題。 在產品列表查看頁面上,查看所有產品的選項僅顯示10個(類別超過10個產品)。 以下是系統配置目錄部分中的一些相關設置:

List Mode: Grid Only
Products per Page on Grid Allowed Values: 8,16,32
Products per Page on Grid Default Value: 8
Allow All Products per Page: Yes

在布局文件THEME / layout / catalog.xml中沒有設置任何明確的限制。

在產品列表視圖上,如果將“ limit”參數設置為允許的整數值之一(8、16、32),則該列表將按預期工作。 但是,如果使用參數“ limit = all”,則僅顯示10個產品。

使用firephp擴展名查看具有184個產品的類別的產品列表頁面,我看到以下內容:

limit=16
THEME/template/catalog/product/list.phtml: $this->getLoadedProductCollection()->count() returns 16
THEME/template/catalog/product/list/toolbar.phtml: $this->getCollection()->getSize() returns 184

limit=all
THEME/template/catalog/product/list.phtml: $this->getLoadedProductCollection()->count() returns 10
THEME/template/catalog/product/list/toolbar.phtml: $this->getCollection()->getSize() returns 184

我已經查看了Mage_Catalog_Block_Product_List中的_getProductCollection()方法,但是沒有在任何地方看到設置的查詢限制。 有什么想法來自這個限制10,或者如何使“所有”限制正常工作?

更新資料

count()和getSize()在THEME / template / catalog / product / list.phtml中返回不同的值

limit=16
THEME/template/catalog/product/list.phtml: $this->getLoadedProductCollection()->count() returns 16
THEME/template/catalog/product/list.phtml: $this->getLoadedProductCollection()->getSize() returns 184
THEME/template/catalog/product/list/toolbar.phtml: $this->getCollection()->getSize() returns 184

limit=all
THEME/template/catalog/product/list.phtml: $this->getLoadedProductCollection()->count() returns 10
THEME/template/catalog/product/list.phtml: $this->getLoadedProductCollection()->getSize() returns 184
THEME/template/catalog/product/list/toolbar.phtml: $this->getCollection()->getSize() returns 184

這僅發生在我的自定義主題中。 如果將主題切換為“基本”包,則limit = all條件為count()和getSize()返回184個產品。 我的自定義主題僅對list.phtml進行了少量標記/ CSS更改(PHP代碼相同)。

尋呼機是元凶。 1.4版之前的Magento主題在THEME / template / catalog / category / view.phtml中利用了一些Pager邏輯。 在1.4.x中,已對Pager進行了修訂,並且需要設置一個明確的限制,以便在類別視圖頁面上使用。

這里的提示是,如果您發現自己實例化了“ product_list_toolbar_pager”,請確保將限制設置為與工具欄上使用的限制相同。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM