News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

order by - reverse order

Started by jankoo, November 19, 2017, 22:46:16 PM

Previous topic - Next topic

jankoo

hi,
i have vm3 eshop.

in category layout there is option to sort products by.. for example by the "price".. (and i can choose in the backend if its ascending/descending)..

but how to let customers in fronted to reverse the order by ascending/descending ??
we use custom template override. but i dont see this also in vm core template layout code.

if its core function please let me know where i can find it. if its possible with the code please let me know the code.
thanks

jenkinhill

The order change option is present in the default VM templates. See here in VM3.2.4



The code is in root/components/com_virtuemart/views/category/tmpl/default.php which I guess you are overriding.
Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

jankoo

hi.. thx for the answer..

ok. i found that code.. but only what i see in that file is  <?php echo $this->orderByList['orderby']; ?>

and its working as you need to click on the same title of the orderby again.. its not very UX friendly.. i want to have icon next to the dropdown list. icon asc or dsc.. so where is the orderby layout code really happening? so i can try to play with it..


Ghost

See getOrderByList function in product model (/administrator/components/com_virtuemart/models/product.php).

jbrailas

So, you have to edit core files to change this function.
I agree that this is not very user friendly, the developers should consider to improve it.
The majority of the other eCommerce platforms has the option to edit easily the order by function.

jbrailas

Well I guess it can be done without editing the core files.
Just override the default.php of category view (com_virtuemart) and go to line 200 and edit just like that:

   <?php
      $orderASC = 'ASC';
      $orderDESC = 'DESC';
      // CUSTOM!!! echo $this->orderByList['orderby']; ?>
      <div class="orderlistcontainer">
         <div class="title">Order by: </div>
         <div class="activeOrder">
            <a>Order by:</a>
         </div>
         <div class="orderlist">
            <div>
               <?php
                  $urlLink = vmURI::getCurrentUrlBy('request', false, true, array('orderby','dir'));
                  $orderby = 'product_name';
                  $orderDirLink = '&dir=' . $orderASC;
                  $orderbyTxt = '&orderby=' . $orderby;
                  $link = JRoute::_ ($urlLink . $orderbyTxt . $orderDirLink,false);
               ?>
               <a title="Product Name" href="<?php echo $link; ?>">Name, A to Z</a>
            </div>
            <div>
               <?php
                  $urlLink = vmURI::getCurrentUrlBy('request', false, true, array('orderby','dir'));
                  $orderby = 'product_name';
                  $orderDirLink = '&dir=' . $orderDESC;
                  $orderbyTxt = '&orderby=' . $orderby;
                  $link = JRoute::_ ($urlLink . $orderbyTxt . $orderDirLink,false);
               ?>
               <a title="Product Name" href="<?php echo $link; ?>">Name, Z to A</a>
            </div>            
            <div>
               <?php
                  $urlLink = vmURI::getCurrentUrlBy('request', false, true, array('orderby','dir'));
                  $orderby = 'product_price';
                  $orderDirLink = '&dir=' . $orderASC;
                  $orderbyTxt = '&orderby=' . $orderby;
                  $link = JRoute::_ ($urlLink . $orderbyTxt . $orderDirLink,false);
               ?>
               <a title="Product Price" href="<?php echo $link; ?>">Price, low to high</a>
            </div>
            <div>
               <?php
                  $urlLink = vmURI::getCurrentUrlBy('request', false, true, array('orderby','dir'));
                  $orderby = 'product_price';
                  $orderDirLink = '&dir=' . $orderDESC;
                  $orderbyTxt = '&orderby=' . $orderby;
                  $link = JRoute::_ ($urlLink . $orderbyTxt . $orderDirLink,false);                  
               ?>            
               <a title="Product Price" href="<?php echo $link; ?>">Price, high to low</a>
            </div>            
         </div>
      </div>