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/

eZ debug

Timing: Jan 19 2025 10:00:05
Script start
Timing: Jan 19 2025 10:00:05
Module start 'content'
Timing: Jan 19 2025 10:00:05
Module end 'content'
Timing: Jan 19 2025 10:00:05
Script end

Main resources:

Total runtime0.1396 sec
Peak memory usage4,096.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0064 590.1016180.8359
Module start 'content' 0.00640.0058 770.937597.9922
Module end 'content' 0.01220.1273 868.9297526.8047
Script end 0.1395  1,395.7344 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00362.5637200.0002
Check MTime0.00130.9575200.0001
Mysql Total
Database connection0.00080.593310.0008
Mysqli_queries0.092065.89291410.0007
Looping result0.00120.86421390.0000
Template Total0.126991.010.1269
Template load0.00080.596010.0008
Template processing0.126190.359510.1261
Override
Cache load0.00060.418510.0006
Sytem overhead
Fetch class attribute can translate value0.00060.430610.0006
XML
Image XML parsing0.00030.196410.0003
General
dbfile0.00664.7505200.0003
String conversion0.00000.005130.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs