Author Topic: HELP!!! - Can't Manually Change the Sort Order for Products in Frontend  (Read 61044 times)

flavorgrafix

  • Beginner
  • *
  • Posts: 1
In the 1.1.0 wiki it clearly states that:

"It's now possible to re-order products in a category and create a sort order that is independent of price, name or date."

http://dev.virtuemart.net/cb/wiki/1353

But how exactly does this work? In the back-end, I try to use the change order column by renumbering the order of products, then I click the small disk icon and the order changes in the list  but that change does not reflect on the front end. The order doesn't change.

Then I try the arrows in the reorder column and they do nothing either.

Is my VM install broken? Or is this feature not working yet?
I don't want to have to do it by SKU's or alphabetically or price.

I am using Virtuemart 1.1.0 and Joomla! 1.5.2 Production/Stable

billsfriends

  • Beginner
  • *
  • Posts: 8
I concur Mr. Flavor, very frustrating. What's the point of a sort order on the back end?? I want to be able to sort on the front end free of name, date and sku.

I wish someone had a fix for this

billsfriends

  • Beginner
  • *
  • Posts: 8
anyone have a fix for this issue??

thomas2411

  • Beginner
  • *
  • Posts: 18
Hi guys,
I also had this problem but I succeeded in adding some code in order to make it work. Here is a solution.


File:
administrator\components\com_virtuemart\html\admin.show_cfg.php

Find

Code: [Select]
    <tr>
        <td class="labelcell"><?php echo $VM_LANG->_('VM_BROWSE_ORDERBY_DEFAULT_FIELD_LBL'?></td>
        <td>
                <select class="inputbox" name="conf_VM_BROWSE_ORDERBY_FIELD">
                        <option value="product_name" <?php if (@VM_BROWSE_ORDERBY_FIELD == 'product_name') echo "selected=\"selected\""?>><?php echo $VM_LANG->_('PHPSHOP_PRODUCT_NAME_TITLE'?></option>
                        <option value="product_price" <?php if (@VM_BROWSE_ORDERBY_FIELD == 'product_price') echo "selected=\"selected\""?>><?php echo $VM_LANG->_('PHPSHOP_PRODUCT_PRICE_TITLE'?></option>
                        <option value="product_sku" <?php if (@VM_BROWSE_ORDERBY_FIELD == 'product_sku') echo "selected=\"selected\""?>><?php echo $VM_LANG->_('PHPSHOP_CART_SKU'?></option>
                        <option value="product_cdate" <?php if (@VM_BROWSE_ORDERBY_FIELD == 'product_cdate') echo "selected=\"selected\""?>><?php echo $VM_LANG->_('PHPSHOP_LATEST'?></option>
            </select>
        </td>
        <td><?php echo vmToolTip$VM_LANG->_('VM_BROWSE_ORDERBY_DEFAULT_FIELD_LBL_TIP') ) ?></td>
    </tr>

And add new option to input, type select:

Code: [Select]
                        <option value="product_list" <?php if (@VM_BROWSE_ORDERBY_FIELD == 'product_list') echo "selected=\"selected\""?>><?php echo $VM_LANG->_('PHPSHOP_PRODUCT_ORDER_DEFAULT_MODIFIED'?></option>

Find:

Code: [Select]
    <tr>
        <td class="labelcell"><?php echo $VM_LANG->_('VM_BROWSE_ORDERBY_FIELDS_LBL'?></td>
        <td>
                        <input name="conf_VM_BROWSE_ORDERBY_FIELDS[]" type="checkbox" value="product_name" <?php if (in_array'product_name'$VM_BROWSE_ORDERBY_FIELDS )) echo "checked=\"checked\""?> id="conf_VM_BROWSE_ORDERBY_FIELDS1" />
                        <label for="conf_VM_BROWSE_ORDERBY_FIELDS1"><?php echo $VM_LANG->_('PHPSHOP_PRODUCT_NAME_TITLE'?></label><br />
           
                        <input name="conf_VM_BROWSE_ORDERBY_FIELDS[]" type="checkbox" value="product_price" <?php if (in_array'product_price'$VM_BROWSE_ORDERBY_FIELDS )) echo "checked=\"checked\""?> id="conf_VM_BROWSE_ORDERBY_FIELDS2" />
                        <label for="conf_VM_BROWSE_ORDERBY_FIELDS2"><?php echo $VM_LANG->_('PHPSHOP_PRODUCT_PRICE_TITLE'?></label><br />

                        <input name="conf_VM_BROWSE_ORDERBY_FIELDS[]" type="checkbox" value="product_cdate" <?php if (in_array'product_cdate'$VM_BROWSE_ORDERBY_FIELDS )) echo "checked=\"checked\""?> id="conf_VM_BROWSE_ORDERBY_FIELDS3" />
                        <label for="conf_VM_BROWSE_ORDERBY_FIELDS3"><?php echo $VM_LANG->_('PHPSHOP_LATEST'?></label><br />

                        <input name="conf_VM_BROWSE_ORDERBY_FIELDS[]" type="checkbox" value="product_sku" <?php if (in_array'product_sku'$VM_BROWSE_ORDERBY_FIELDS )) echo "checked=\"checked\""?> id="conf_VM_BROWSE_ORDERBY_FIELDS4" />
                        <label for="conf_VM_BROWSE_ORDERBY_FIELDS4"><?php echo $VM_LANG->_('PHPSHOP_CART_SKU'?></label>
        </td>
        <td><?php echo vmToolTip$VM_LANG->_('VM_BROWSE_ORDERBY_FIELDS_LBL_TIP') ) ?></td>
    </tr>

And add new checkbox

Code: [Select]
<input name="conf_VM_BROWSE_ORDERBY_FIELDS[]" type="checkbox" value="product_list" <?php if (in_array'product_list'$VM_BROWSE_ORDERBY_FIELDS )) echo "checked=\"checked\""?> id="conf_VM_BROWSE_ORDERBY_FIELDS5" />
                        <label for="conf_VM_BROWSE_ORDERBY_FIELDS5"><?php echo $VM_LANG->_('PHPSHOP_PRODUCT_ORDER_DEFAULT_MODIFIED'?></label>


File:
administrator\components\com_virtuemart\html\shop_browse_queries.php

Find:


Code: [Select]
switch( $orderby ) {
case 'product_name':
$orderbyField = '`#__{vm}_product`.`product_name`'; break;
case 'product_price':
$orderbyField = '`#__{vm}_product_price`.`product_price`'; break;
case 'product_sku':
$orderbyField = '`#__{vm}_product`.`product_sku`'; break;
case 'product_cdate':
$orderbyField = '`#__{vm}_product`.`cdate`'; break;
default:
$orderbyField = '`#__{vm}_product`.`product_name`'; break;
}


And add new case:


Code: [Select]
case 'product_list':
$orderbyField = '`#__{vm}_product_category_xref`.`product_list`'; break;
}


File:
components\com_virtuemart\themes\default\templates\browse\includes\browse_orderbyfields.tpl.php

Find:


Code: [Select]
// SORT BY PRODUCT NAME
if( in_array( 'product_name', $VM_BROWSE_ORDERBY_FIELDS)) { ?>
        <option value="product_name" <?php echo $orderby=="product_name" "selected=\"selected\"" "";?>>
        <?php echo $VM_LANG->_('PHPSHOP_PRODUCT_NAME_TITLE'?></option>
<?php
}

And add before it or wherever you want - it is up to you which option will be shown in which order "in sort by list"


Code: [Select]
// SORT BY MY OWN ORDER - MOJA ZMIANA
if( in_array( 'product_list', $VM_BROWSE_ORDERBY_FIELDS)) { ?>
        <option value="product_list" <?php echo $orderby=="product_list" "selected=\"selected\"" "";?>>
        <?php echo $VM_LANG->_('PHPSHOP_PRODUCT_ORDER_DEFAULT_MODIFIED_LBL'?></option>
<?php
}


Last thing is to add to your language 2 new variables:

File:
administrator\components\com_virtuemart\languages\common\yourlanguage.php


Code: [Select]
'PHPSHOP_PRODUCT_ORDER_DEFAULT_MODIFIED' => 'Own sort order',
'PHPSHOP_PRODUCT_ORDER_DEFAULT_MODIFIED_LBL' => 'Default sorting',

Of course you can name it as you want :)

Good luck! :)
Tom Ignatiuk

urso.lv

  • Beginner
  • *
  • Posts: 16
Thank you a lot!

I just did those changes and it worked just fine.

Printopia

  • Beginner
  • *
  • Posts: 5
I have more or less the same problem, but then with Child items. When I go to a parent item and click on 'item information', I get a list of the child items. In the front end, these will show up as a drop down menu.

I would like to set the order in the backend, but the arrows don't do anything. If I click them, the page refreshes, but order stays the same. The same happens when I manually fill out the order in numbers and click the 'save' symbol. How to work around this?

I've tried the fix above but it did not work for me. I've probably done something wrong, but I also think (maybe I'm wrong) it's not the solution to my problem?

webrule

  • Beginner
  • *
  • Posts: 23
Hello,

i tried this code but getting error in admin side

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/waterion/public_html/administrator/components/com_virtuemart/html/admin.show_cfg.php on line 792


and on client side this error


Parse error: syntax error, unexpected T_DEFAULT in /home/waterion/public_html/administrator/components/com_virtuemart/html/shop_browse_queries.php on line 58

i inserted the same thing you said but got this error

i basically want sorting by product id

thanks

gavn8r

  • Beginner
  • *
  • Posts: 2
THANK YOU SO MUCH!  This was really driving me crazy and I was trying to find everything I needed to change to order by product_list.  I decided on a whim to do a Google search and I found this post.  Excellent job, thomas2411.  you saved me a lot of work and a huge headache.  Well done.

vbsouthern

  • Beginner
  • *
  • Posts: 16
    • Winning Web Designers
Thank you thomas2411 for your solution to this problem.  You may be a Newbie to the VirtueMart Forum but you are obviously a first rate programmer.  Thanks again.

http://forum.virtuemart.net/index.php?topic=39525.msg131553#msg131553
"Every spot of the old world is overrun with oppression. Freedom hath been hunted round the globe. Asia, and Africa, have long expelled her. Europe regards her like a stranger, and England hath given her warning to depart."

Thomas Paine - Common Sense - 1774

sparkiii

  • Beginner
  • *
  • Posts: 21
Re: HELP!!! - Can't Manually Change the Sort Order for Products in Frontend
« Reply #9 on: August 07, 2008, 00:55:41 am »
HI and thankyou. This is working as far as there are no errors coming up and it all seems fine in the admin, but it doesnt change the sort order in the front end?? Does this make sense. I want to set it Jan - Dec in order.

Mt URL is

http://www.sri.com.au/index.php?option=com_virtuemart&page=shop.browse&category_id=6&Itemid=42

Please see a screen shot of my admin page below.

vbsouthern

  • Beginner
  • *
  • Posts: 16
    • Winning Web Designers
Re: HELP!!! - Can't Manually Change the Sort Order for Products in Frontend
« Reply #10 on: August 07, 2008, 04:34:23 am »
If you followed all of the instructions in the post:
http://forum.virtuemart.net/index.php?topic=39525.msg131553#msg131553
then go to VirtueMart >> Configuration and select the Site tab.  Go to (Default product sort order) and select the Product Order that you defined in the code you changed.
"Every spot of the old world is overrun with oppression. Freedom hath been hunted round the globe. Asia, and Africa, have long expelled her. Europe regards her like a stranger, and England hath given her warning to depart."

Thomas Paine - Common Sense - 1774

sparkiii

  • Beginner
  • *
  • Posts: 21
Re: HELP!!! - Can't Manually Change the Sort Order for Products in Frontend
« Reply #11 on: August 07, 2008, 05:36:12 am »
 ;D Thanks, that did the trick.

ipimen

  • Beginner
  • *
  • Posts: 8
Re: HELP!!! - Can't Manually Change the Sort Order for Products in Frontend
« Reply #12 on: August 10, 2008, 06:25:29 am »
Thanks a lot! Great post thomas2411, clear and flawless. It worked perfectly.

thomas2411

  • Beginner
  • *
  • Posts: 18
Re: HELP!!! - Can't Manually Change the Sort Order for Products in Frontend
« Reply #13 on: August 10, 2008, 12:32:24 pm »
I'm happy to hear that :)

elixa

  • Beginner
  • *
  • Posts: 4
Re: HELP!!! - Can't Manually Change the Sort Order for Products in Frontend
« Reply #14 on: September 08, 2008, 15:36:02 pm »
Dear thomas2411, This worked for me wonderfully just as I was feeling the crushing weight of a nagging client on my back. Wish you well.
thanks again - elixa