VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: mronayne on February 21, 2015, 15:50:14 PM

Title: VirtueMart Category Module - minor ordering issue after 3.0.6 upgrade
Post by: mronayne on February 21, 2015, 15:50:14 PM
Joomla Version 3.4.0

I just upgraded to VM 3.0.6 and the behavior of the VirtueMart Category module changed such that whenever I select a category, the module reorders my categories alphabetically. When I navigate back to the main store page, the categories are back in the order I set them to?

In VM 3.0.4, the order of my categories remains as I set them in the Admin Category ordering - which is how I want this module to behave.

While this may seem like something minor - I prefer that the categories remain in the order I set them to. At least give me a way in the module to disable this automatic alphabetical ordering.

You can see this behavior here: http://cejay2014.cejayengineering.com/products/buy-online  Then just expand any of the categories in the "Product Categories" module.
Title: Re: VirtueMart Category Module - minor ordering issue after 3.0.6 upgrade
Post by: patbe60 on February 22, 2015, 11:26:30 AM
Hello

Same problem here. But it only happens when I have a category with subcategories:
When I click the main category, the other categories change into alphabetic order. When I click a subcategory, the categories change back into the order I have set in the BE.

I have found the problem:

In administrator/components/com_virtuemart/models/category.php there is a new code in line 329:

if(trim($this->_selectedOrdering) == 'c.ordering'){
$this->_selectedOrdering = 'c.ordering, l.`category_name`';
}


When uncommenting this code, the category ordering works fine again.

Maybe there is a setting in the configuration I have not yet found or there is a little error in this code.

Regards
Patrik
Title: Re: VirtueMart Category Module - minor ordering issue after 3.0.6 upgrade
Post by: mronayne on February 22, 2015, 15:50:04 PM
Patrik,

Thank you for your reply. I have a quick question for you though...
I found the code you reference at line 329, but it is already un-commented?

The line above at  328 is commented as is the line below at 332 - is one of these the line you uncommented? Both?


//$selOrdering = $this->_selectedOrdering;
if(trim($this->_selectedOrdering) == 'c.ordering'){
$this->_selectedOrdering = 'c.ordering, l.`category_name`';
}
//$ordering = ' ORDER BY '.$this->_selectedOrdering.' '.$this->_selectedOrderingDir ;

Title: Re: VirtueMart Category Module - minor ordering issue after 3.0.6 upgrade
Post by: mronayne on February 22, 2015, 15:56:01 PM
Patrik,

I figured it out... you must have meant that you commented out this code at 329. After I did that, the ordering remains as I have it configured.

Thanks again!
Regards,
Mike
Title: Re: VirtueMart Category Module - minor ordering issue after 3.0.6 upgrade
Post by: breetlee6666 on February 23, 2015, 06:37:34 AM
There is my shop with parts for jewelery. I'm a programmer and owner of that shop. Of course there is much work to do yet. Thanks Virtuemart team, you did fantastic job.
Title: Re: VirtueMart Category Module - minor ordering issue after 3.0.6 upgrade
Post by: Milbo on February 23, 2015, 10:35:34 AM
The correct code should be
Quote
      if(trim($this->_selectedOrdering) == 'c.ordering'){
         $this->_selectedOrdering = 'c.ordering, l.`category_name`';
      }
      $ordering = $this->_getOrdering();
Patrick maybe uncommented "$this->_selectedOrdering = 'c.ordering, l.`category_name`';"
Actually it should Order first by ordering and if the you have sometimes the same ordering, then by name. Example
Cat A Ordering 2
Cat B Ordering 2
Cat C Ordering 1
=> Cat C, Cat A, Cat B

I found the error, the reason is different


if(trim($this->_selectedOrdering) == 'c.ordering'){
$this->_selectedOrdering = 'c.ordering, category_name';
}


The new selectedOrdering was not in the self::$_validOrderingFields and failed

if(!in_array($selectedOrdering, self::$_validOrderingFields)){
$selectedOrdering = 'category_name';
}

in function getChildCategoryList, the solution is to add 'c.ordering, l.`category_name`' in line 33


static $_validOrderingFields = array('category_name','category_description','c.ordering','c.category_shared','c.published','c.ordering, l.`category_name`');
Title: Re: VirtueMart Category Module - minor ordering issue after 3.0.6 upgrade
Post by: mronayne on February 23, 2015, 15:19:51 PM
I replaced line 33 with your code exactly and now I get the following SQL Error. What did I do wrong?

Unknown column 'l.category_name' in 'order clause' SQL=SELECT L.* FROM `gbo82_virtuemart_categories_en_gb` as L INNER JOIN `gbo82_virtuemart_categories` as c using (`virtuemart_category_id`) LEFT JOIN `gbo82_virtuemart_category_categories` as cx on c.`virtuemart_category_id` = cx.`category_child_id` WHERE cx.`category_parent_id` = 6 AND c.`virtuemart_vendor_id` = 1 AND c.`published` = 1 ORDER BY c.ordering, l.`category_name` ASC
Title: Re: VirtueMart Category Module - minor ordering issue after 3.0.6 upgrade
Post by: Milbo on February 23, 2015, 23:57:32 PM
use category_name anywhere instead of l.category_name or similar. Or just check the svn http://dev.virtuemart.net/projects/virtuemart/repository
Title: Re: VirtueMart Category Module - minor ordering issue after 3.0.6 upgrade
Post by: mronayne on March 04, 2015, 18:32:35 PM
Thank You! This problem is fixed in VM 3.0.6.2
Title: Re: VirtueMart Category Module - minor ordering issue after 3.0.6 upgrade
Post by: d0ublezer0 on March 11, 2015, 14:40:49 PM
VM 3.0.6.2
mod_virtuemart_category
orders alphabetically , instead of backend ordering settings (i use russian language of categories names)
Title: Re: VirtueMart Category Module - minor ordering issue after 3.0.6 upgrade
Post by: mronayne on March 11, 2015, 16:20:02 PM
You can control the Ordering of the Category Module with the Configuration settings on the "Product Order Settings" tab.
To the right of "Default category sort order" selecting "Category Name" will either sort Ascending or Descending based on your choice. Selecting "Ordering, Name" will sort by your Category ordering.
At least this is how it is working for me. Seems reasonable?
Title: Re: VirtueMart Category Module - minor ordering issue after 3.0.6 upgrade
Post by: d0ublezer0 on March 12, 2015, 07:31:51 AM
Quote from: mronayne on March 11, 2015, 16:20:02 PM
You can control the Ordering of the Category Module with the Configuration settings on the "Product Order Settings" tab.
To the right of "Default category sort order" selecting "Category Name" will either sort Ascending or Descending based on your choice. Selecting "Ordering, Name" will sort by your Category ordering.
At least this is how it is working for me. Seems reasonable?
Unfortunately, there are no Ordering tab (vm 3.0.6.2, J2.5.24):
(http://f6.s.qip.ru/LHJwjx4Q.png)
Title: Re: VirtueMart Category Module - minor ordering issue after 3.0.6 upgrade
Post by: jenkinhill on March 12, 2015, 10:58:35 AM
The setting is not in the module it is in VM Configuration/Product Order Settings  as  Default category sort order  - this affects the module and the category listing order.
Title: Re: VirtueMart Category Module - minor ordering issue after 3.0.6 upgrade
Post by: d0ublezer0 on March 12, 2015, 11:00:51 AM
Quote from: jenkinhill on March 12, 2015, 10:58:35 AM
The setting is not in the module it is in VM Configuration/Product Order Settings  as  Default category sort order  - this affects the module and the category listing order.
OMG, thank you!
Title: Re: VirtueMart Category Module - minor ordering issue after 3.0.6 upgrade
Post by: kaybee57 on March 17, 2015, 00:11:33 AM
Quote from: mronayne on March 04, 2015, 18:32:35 PM
Thank You! This problem is fixed in VM 3.0.6.2
Agreed - quick update and ordering now works! Thank you folks!
Title: Re: VirtueMart Category Module - minor ordering issue after 3.0.6 upgrade
Post by: Milbo on March 18, 2015, 01:27:41 AM
But http://forum.virtuemart.net/index.php?topic=128807.0
Title: Re: VirtueMart Category Module - minor ordering issue after 3.0.6 upgrade
Post by: Mentalhacker on May 19, 2018, 14:46:06 PM
Unfortunately, the ordering problem returned.

In VM 3.2.14, changing the category ordering in the config does not have any effect on the Virtuemart Category Module. This module always shows the category names in alphabetical order, no matter what is set in the config.
Title: Re: VirtueMart Category Module - minor ordering issue after 3.0.6 upgrade
Post by: jenkinhill on May 19, 2018, 15:35:39 PM
I have 3.2.15 and the module display order of categories is as set in the Ordering column on the category list.
Title: Re: VirtueMart Category Module - minor ordering issue after 3.0.6 upgrade
Post by: Mentalhacker on May 19, 2018, 15:49:45 PM
Sorry, meanwhile I figured out that it was not a VM setting problem but a VMuikit default setting (category alphabet). The config works fine.
Title: Re: VirtueMart Category Module - minor ordering issue after 3.0.6 upgrade
Post by: sandomatyas on September 18, 2020, 08:05:48 AM
In VirtueMart 3.8.4 10335 the code is:
VirtueMartModelCategory::rekurseCategories($vendorId, $category_id, $categories, $level, 0, 0,true, '', 'c.ordering, category_name', 'ASC', true);

Does it mean the ordering is fixed to c.ordering?
Title: Re: VirtueMart Category Module - minor ordering issue after 3.0.6 upgrade
Post by: pinochico on September 18, 2020, 10:32:15 AM
QuoteDoes it mean the ordering is fixed to c.ordering?

Go to PHPMYADMIN and look self. I think yes
Title: Re: VirtueMart Category Module - minor ordering issue after 3.0.6 upgrade
Post by: sandomatyas on September 18, 2020, 12:50:47 PM
Shouldn't it use the global settings?