English 中文(简体)
先是按职位分类收集选项?
原标题:magento sort attribute option collection by position?

Greetings,

我试图通过管理属性小组中的“定位”来分类一系列归属选择价值。 我似乎尝试了一切,谁知道这样做是可能的?

我相信,这将发挥作用:

    $_collection = Mage::getResourceModel( eav/entity_attribute_option_collection )
        ->setStoreFilter(0)
        ->setAttributeFilter($_productAttribute->getId())
        ->addAttributeToSort( position )
        ->load();

但它没有。 任何帮助都将受到高度赞赏。

问题回答

I ve alredy曾经历过添加字典。 在前一个项目中,或许这一功能会起作用,直到今天才尝试用组装(一栏)或试图将母体更新到最后版本。

Working great. In Magento 1.6 + use setOrder( sort_order ).

$attribute = Mage::getModel( eav/entity_attribute )->load( $code,  attribute_code );
$option_col = Mage::getResourceModel(  eav/entity_attribute_option_collection )
 ->setAttributeFilter( $attribute->getId() )
 ->setStoreFilter()
 ->setPositionOrder(  ASC  );
$option_col->getSelect()->order( main_table.sort_order  .$orderby);

在设计/设计/对抗/default/default/template/manapro/filtercheck Boxes/items.phtml的开头处添加以下代码:

function cmp($a, $b){
  if ($a == $b)
    return 0;
  return ($a[ position ] < $b[ position ]) ? -1 : 1;
}
$array = $this->getItems();
usort($array, "cmp");

And replace $this->getItems() with $array in foreach loop.

在收集时,装满负荷就与收集和使用负荷功能的盘问。 您

Mage::getResourceModel( eav/entity_attribute_option_collection )

就像:

$_collection = Mage::getResourceModel( eav/entity_attribute_option_collection )->getSelect()->order( main_table.sort_order  .$orderby);
        $_collection->setStoreFilter(0)
        ->setAttributeFilter($_productAttribute->getId())
        ->load();




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签