English 中文(简体)
Magento - Sort Products by ID
原标题:Magento - Sort Products by ID

我正试图设立我的Magento仓库,以便把产品分类,以便将这些产品添加到水泥).中(产品识别)。 然而,我没有能够找到一个很好的例子,说明如何建立这一机制。 在我的大多数产品类别中,似乎都是如此,但并非全部。

我认为,在前言采用“政治”办法就是这样做的,但似乎没有为我的所有类别工作。 我正在使用社区版本1.6.1。

提前感谢!

问题回答

Copy :
app/code/core/Mage/Catalog/Block/Product/List.php

to (create the appropiate folder ):
app/code/local/Mage/Catalog/Block/Product/List.php

Find the following line in List.php :

$this->_productCollection = $layer->getProductCollection();

添加以下一行:

$this->_productCollection->joinField( category_product ,  catalog/category_product ,  product_id ,  product_id=entity_id , array( store_id => Mage::app()->getStore()->getId()),  left );

// Here is the explain
/*
* @param string $alias  category_product 
* @param string $table  catalog/category_product 
* @param string $field  name 
* @param string $bind  PK(product_id)=FK(entity_id) 
* @param string|array $cond
* @param string $joinType  left 
*
* default definition
* joinField($alias, $table, $field, $bind, $cond=null, $joinType= inner ) 
*
*/

Copy
app/code/core/Mage/Catalog/Model/Config.php

to
app/code/local/Mage/Catalog/Model/Config.php

Find the following line in Config.php :

 position   => Mage::helper( catalog )->__( Position )

改为:

$options = array(
    position   => Mage::helper( catalog )->__( Position ),
    product_id  => Mage::helper( catalog )->__( Product ID )
); 

PS: 我是在我的机器上安装马亨托的家中撰写这一文章,因此,我进行了笔试,但结构是科索沃。 如果你面临任何可笑之处,就会确保实地和表格名称。

Just in case someone needs: Change this:

 product_id  => Mage::helper( catalog )->__( Product ID )

为此:

 entity_id  => Mage::helper( catalog )->__( Product ID )

页: 1

app/code/core/Mage/Catalog/Model/Config.php

纽约总部

app/code/local/Mage/Catalog/Model/Config.php

在<代码>上填写以下条目: Config.php:

$options = array(
     position   => Mage::helper( catalog )->__( Position )
);

改为:

    $options = array(
//         position   => Mage::helper( catalog )->__( Position )
         entity_id  => Mage::helper( catalog )->__( Last )
    );

then change the default sorting direction 纽约总部 descending: open app/design/frontend/your theme/your layout/layout/catalog.xml add the line

<action method="setDefaultDirection"><dir>desc</dir></action>

页: 1

<block type="catalog/product_list_纽约总部olbar" name="product_list_纽约总部olbar" template="catalog/product/list/纽约总部olbar.phtml">
   <block type="page/html_pager" name="product_list_纽约总部olbar_pager"/>
      <!-- The following code shows how 纽约总部 set your own pager increments -->
here

   </block>
</block>




相关问题
How do I sort enum members alphabetically in Java?

I have an enum class like the following: public enum Letter { OMEGA_LETTER("Omega"), GAMMA_LETTER("Gamma"), BETA_LETTER("Beta"), ALPHA_LETTER("Alpha"), private final String ...

Grokking Timsort

There s a (relatively) new sort on the block called Timsort. It s been used as Python s list.sort, and is now going to be the new Array.sort in Java 7. There s some documentation and a tiny Wikipedia ...

Sorting twodimensional Array in AS3

So, i have a two-dimensional Array of ID s and vote count - voteArray[i][0] = ID, voteArray[i][1] = vote count I want the top 3 voted items to be displayed in different colors, so i have a 2nd Array -...

Linq operations against a List of Hashtables?

I m working with a set of legacy DAO code that returns an IList, where each Hashtable represents the row of a dynamically executed SQL query. For example, the List might contain the following records/...

C++ Array Sort Me

Stuck on an array sorter. Have to sort numbers from largest to smallest. I m trying two loops (one nested in the other). Here s the code: int counter=0; // inner counter int counter2=0; // outer ...

Can I Nest OrderBy in .NET?

This doesn t seem to work as I intend. VB.NET: Dim x = Model.Discussions.OrderByDescending(Function(d) d.Messages.OrderByDescending(Function(m) m.Sent).First.Sent) For Each d As Discussion In x ....

sorting elements javascript

I m looking for a way to sort my elements, but it isn t as easy as it sounds. Please let me explain My elements are grouped per 6 elements (thumbnails), each x represents a thumbnail However all ...

热门标签