We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37140
    • 16 Posts
    Tell me please, how can I do sort by sortbyTV for two parameters (size and price)?

    Example, I've got the table:

    Name___Size____Price
    Shirt___46_________6
    Shirt___46_________2
    Shirt___44_________2
    Shirt___47_________4
    Shirt___44_________8
    Shirt___47_________2

    And I've got this query:
    [[!getResources?  
            &parents=`2`
            &limit=`50`
            &tpl=`product`
            &showHidden=`0`
            &includeTVs=`1`
            &sortbyTV=`size` (I want add price)
            &sortdirTV=`ASC`
            &sortbyTVType=`integer`
            &toPlaceholder=`results`
            &hideContainers=`1`
    ]]


    I need to get this table (sort by Size and sort by Price):
    Name___Size____Price
    Shirt___44_________2
    Shirt___44_________8
    Shirt___46_________2
    Shirt___46_________6
    Shirt___47_________2
    Shirt___47_________4
      • 4172
      • 5,888 Posts
      I think this is not possible with getResources

      But its possible with pdoResources (included with the pdoTools - package) like that:

      [[!pdoResources? 
              &parents=`2`
              &limit=`50`
              &tpl=`product`
              &showHidden=`0`
              &includeTVs=`size,price`
              &sortby=`{"size":"ASC","price":"ASC"}`
              &toPlaceholder=`results`
              &hideContainers=`1`
      ]]


      your TVs should be of type number to be sorted correctly
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 37140
        • 16 Posts
        Quote from: Bruno17 at Apr 25, 2014, 02:48 PM
        I think this is not possible with getResources

        But its possible with pdoResources (included with the pdoTools - package) like that:

        [[!pdoResources? 
                &parents=`2`
                &limit=`50`
                &tpl=`product`
                &showHidden=`0`
                &includeTVs=`size,price`
                &sortby=`{"size":"ASC","price":"ASC"}`
                &toPlaceholder=`results`
                &hideContainers=`1`
        ]]


        your TVs should be of type number to be sorted correctly

        Thanks!

        How can I do type number for TVs?

        The parameter &sortbyTVType=`integer` doesnt work.
          • 4172
          • 5,888 Posts
          the TV's input-type should be 'Number' (check it in the input-options of your TV)

          pdoTools (pdoFetch::addSort) does automatically CAST to DECIMAL, when the type of your TV is 'Number'
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
            • 37140
            • 16 Posts
            Thanks!