1. 程式人生 > >magento如何改變產品的排序方式

magento如何改變產品的排序方式

magento中可以方便的設定前臺產品的排序方式,我們可以設定sotr by為price,name,best value及其他一些attribute,以滿足排序要求。magento預設的是Best Value,那到底什麼是Best Value呢?

在官方手冊上有麼兩段解釋 version 1.7:
page 75./85. “Product Listing Sort By: The products are sorted, by default, by the selected attribute. The Best Value products are featured products as determined by the store administrator; for more information, see “Creating Categories,” page 83. The customer can select from the other options on a per-page basis. You can configure attributes to be used for sorting using the Used for Sorting in Product Listing setting of an attribute. For details, see “Managing Product Attributes,” page 92.”

page 88./98. “3. In the Position column, specify a whole number that indicates the order in which the product is listed when the products are sorted by Best Value. The product with a Position value of 1 is listed first, 2 is listed second, and so on. If more than one product has the same value for Position, the product with the lowest (that is, closest to 1) ID number is listed first.”

以管理員進入後臺 (Catalog/Manage Categories),選擇“Category Products” 這個tab,我們能看到這個分類下的所有產品,你會發現最後一個欄位position,其實Best Value就是它決定的,position的值是一個整數,值是1的產品比值是2的產品優先顯示,以此類推;如果多個產品的position相同,按產品ID由小到大優先顯示,即product id接近1的產品先顯示。


改變position的值,儲存;在前臺此分類頁就會發現產品已經按照你設定的position值顯示了(如果預設排序方式為position)。

有關排序的兩種配置
1為每個category設定排序
以管理員進入後臺 (Catalog/Manage Categories),點選Display Settings這個tab,在這裡可以設定“Available Product Listing Sort By” 和“Default Product Listing Sort By”的值 。
先修改“Default Product Listing Sort By”,取消“Use Config Settings”,假設選擇“Default Product Listing Sort By”為“Price”,在前臺將會看到產品按照price升序排列;另外我們可以取消 “Use All Available Attributes” ,假設“Available Product Listing Sort By” 只選擇“Best Value” 和“Price”,在前臺會發現sort by只有“Best Value” 和“Price”可供選擇排序了;儲存後如圖所示:



2為Store / Website / Default Config設定排序
管理員進入後臺System / Configuration / Catalog (left menu) / Frontend ,會看到下拉框Product Listing Sort by,這個地方的排序選擇,將會應用到Store或 Website或Default下的所有產品,至於應用到哪一個在左上角Current Configuration Scope處決定。但是要注意的是,這個配置的優先順序是低於前面category的。



Magento 排序時查詢配置的步驟
1:先找Category配置,沒有則找2
2:找Store配置,沒有則找3
3:找Website配置,沒有則找4
4:找Default Config

最後我們可以在table core_config_data,或者 config.xml file ( app/code/core/Mage/Catalog/etc/config.xml  723行. – position)找到magento預設的排序是Position (“Best Value”);

本文連結地址 jonas的magento部落格