eZ Community » Forums » Setup & design » Can a fetch be sorted by price?
expandshrink

Can a fetch be sorted by price?

Can a fetch be sorted by price?

Monday 16 February 2004 11:36:14 pm - 4 replies

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

Modified on Monday 16 February 2004 11:37:36 pm by Alex Jones

Tuesday 17 February 2004 9: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/documenta...reference/data_fetching/content/list

Tuesday 17 February 2004 4:51:31 pm

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

Guess I need to find a way to hack it.

Alex

Wednesday 03 August 2005 9: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 !

Wednesday 03 August 2005 11: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?

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu