Forums / Setup & design / Can a fetch be sorted by price?

Can a fetch be sorted by price?

Author Message

Alex Jones

Monday 16 February 2004 2:36:14 pm

I have the following code which is set up to sort the items of the fetch by an attribute (id: 162) which happens to be a price. But the results are not sorted by price. When I switch the attribute ID to another one within the same class such as the item number (Text Field), it is sorted properly. Am I missing something, or is sorting by Price not an option?

{let name=Child children=fetch('content','tree',
                                hash(parent_node_id,$parent_node,
                                     sort_by,array(array('attribute',false(),162)),
                                     limit,$page_limit,
                                     offset,$view_parameters.offset,
                                     depth_operator,eq,
                                     class_filter_type, "include",
                                     class_filter_array, array(14)))}

Thanks,

Alex

Alex
[ bald_technologist on the IRC channel (irc.freenode.net): #eZpublish ]

<i>When in doubt, clear the cache.</i>

Balazs Halasy

Tuesday 17 February 2004 12:04:50 am

Hi,

Copy & paste from the docs:

A collection of nodes can be sorted on the attribute level. This means that it is possible to sort a bunch of nodes (of the same type) by one of the attributes; for example sort nodes that contain information about people on the attribute that contains the nickname. The following datatypes support sorting on attribute level:

-ezboolean
-ezdate
-ezdatetime
-ezemail
-ezinteger
-ezselection (will not work when used as multiple selector)
-ezstring
-eztime

..don't see the price datatype there.. so, I guess it is not possible at the moment. However, shouldn't be to hard to hack that in.

Balazs

PS: The docpage is: http://ez.no/ez_publish/documentation/reference/data_fetching/content/list

Alex Jones

Tuesday 17 February 2004 7:51:31 am

Ahhh... I can't believe I missed that documentation page. Thanks!

Guess I need to find a way to hack it.

Alex

Alex
[ bald_technologist on the IRC channel (irc.freenode.net): #eZpublish ]

<i>When in doubt, clear the cache.</i>

Eirik Alfstad Johansen

Wednesday 03 August 2005 12:47:59 am

Hi Alex,

Were you able to hack this, and if so, would you be so kind as to give me a hint regarding how you did it?

Thanks in advance !

Sincerely,

Eirik Alfstad Johansen
http://www.netmaking.no/

Eirik Alfstad Johansen

Wednesday 03 August 2005 2:51:56 am

Hi again,

I've done some digging, and so far I've added the following two methods to kernel/classes/datatypes/ezprice/ezpricetype.php.

function &sortKey( &$contentObjectAttribute )
    {
        return $contentObjectAttribute->attribute( 'data_float' );
    }

    /*!
     \reimp
    */
    function &sortKeyType()
    {
        return 'int';
    }

However, this doesn't appear to be sufficient to get the sorting working.

Could someone please help me along, here?

Sincerely,

Eirik Alfstad Johansen
http://www.netmaking.no/