回答
在管理
轉到管理類別,選擇類別,那麼它的產品標籤上給每一個位置編號。他們將按照該順序排序。
編程
你可以通過調用一個產品集合的每個排序addAttributeToSort
方法做到這一點。
例如,無論您在模板中看到什麼,$_category->getProductCollection()
或$_product->getCollection()
然後您可以在它之後立即添加->addAttributeToSort('position')->addAttributeToSort('name')
。
addAttributeToSort()
也採取方向作爲第二個參數,所以你可以有addAttributeToSort('name', 'asc')
或addAttributeToSort('name', 'desc')
。
相反的編碼,您可以在管理端的.login這樣做是爲了你的adminpanel 轉到系統--->配置並選擇目錄從左邊的標籤。
然後點擊右邊的Fronend標籤。 Goto Product Lisiting排序方式並從下拉列表中選擇名稱並保存配置。
使排序相對容易。在magento市場有一個擴展。此擴展程序將幫助您按照我們的願望將產品拖放到位置。我下面提供
http://www.magentocommerce.com/magento-connect/product-sorting-sequence-drag-and-drop.html
的最佳方式擴展鏈接去了解它在不改變任何核心文件是複製位於Toolbar.php文件:
/app/code/core/Mage/Catalog/Block/Product/List/Toolbar.php
然後創建一個新的目錄路徑下(如果您尚未創建一個):
/app/code/local/Mage/Catalog/Block/Product/List/Toolbar.php
現在從替換232線以下:
if ($this->getCurrentOrder()) {
$this->_collection->setOrder($this->getCurrentOrder(), $this->getCurrentDirection());
}
到
if ($this->getCurrentOrder()) {
if(($this->getCurrentOrder())=='position'){ //defines the sort option
//sort by position (ascending) and entity_id (descending)
$this->_collection->addAttributeToSort('position','asc')->addAttributeToSort('entity_id','desc');
} else {
$this->_collection->setOrder($this->getCurrentOrder(),$this->getCurrentDirection());
}
}
最後,重新索引和刷新你的Magento後端緩存,你準備好了。如果您需要定義一個以上的排序選項複製和粘貼下面的代碼之前)其他(
if(($this->getCurrentOrder())=='######'){ //defines the sort option
//sort by ###### (ascending) and ###### (descending)
$this->_collection->addAttributeToSort('######','asc')->addAttributeToSort('######','desc');
針對clockworkgeek,
一個產品可以有多個屬性。當您爲每個產品分配一個位置時,它與1個屬性相關。另外,您需要爲每個產品決定一個職位。
這裏的問題是產品列表頁面上的下拉菜單爲您提供了選擇多個屬性中的一個的機會。例如:
尺碼:S,M,L,XL
當你選擇一個屬性,默認的是那種屬性按字母順序排列這是沒有意義的(L,M,S,XL)。相反,我想使用屬性選項(s = 1,m = 2,l = 3,xl = 4)的相同位置進行排序。
我的印象是,通過在Magento集合中執行連接和訂購,可以做到這一點。你知道如何獲得這些價值或做這樣的排序嗎?
- 1. 按大小寫和按名稱排序
- 2. 按名稱排序升序
- 3. 按名稱排序elasticsearch
- 4. 訪問按名稱排序
- 5. 按名稱排序屬性
- 6. glob() - 按名稱排序
- 7. 按名稱排序TreeView
- 8. 按名稱排序FileSystemInfo []
- 9. 按列名稱排序
- 10. 按ID排序然後按名稱比按名稱排序更快?
- 11. 按組排列並按位置排序
- 12. 排序TableView按位置?
- 13. aop.xml的名稱和位置?
- 14. mySQL jar名稱和位置
- 15. 在magento中更改產品標籤的名稱和位置
- 16. 添加按價格排序並按名稱排序
- 17. 排名前10位,但按字母順序排序,然後按排名。 SQL
- 18. 排序名稱
- 19. MySQL - 我們可以按列位置而不是名稱來排序嗎?
- 20. 按名稱排序sql查詢
- 21. 按名稱排序,但忽略引號?
- 22. jqGrid排序索引按列名稱
- 23. Unix的'ls'按名稱排序
- 24. 按屬性名稱排序JavaScript對象
- 25. XSLT按名稱排序節點?
- 26. R - 按編號排序列表名稱
- 27. [Python]按字母順序排列名稱
- 28. 按名稱排序python字典?
- 29. 如何按名稱排序`docker service ls`
- 30. 按python名稱排序列表
可以在list.phtml文件中添加它,還是需要在我本地複製的core/mage/catalog/block/product/list.php中的list.php文件中?我試過它在list.phtml頂部我添加位置和名稱<?php $ _productCollection = $ this-> getLoadedProductCollection()?>所以我得到<?php $ _productCollection = $ this-> getLoadedProductCollection() - > addAttributeToSort('position') - > addAttributeToSort('name')?>或者這是在一個階段太晚了。 – Knade 2010-11-15 08:42:45
它現在的工作程度Clockworkgeek,但它總是採取任何第二個屬性,它似乎是專門應用它們而不是在一起。 – Knade 2010-11-15 10:36:14