VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: thewitt on April 12, 2015, 09:05:36 AM

Title: Shoppers error VM 3.0.7.2 J3.4.1
Post by: thewitt on April 12, 2015, 09:05:36 AM
If I select Shoppers from the Virtuemart menu, I get the following error:

1052 Column 'virtuemart_user_id' in order clause is ambiguous SQL=SELECT SQL_CALC_FOUND_ROWS ju.id AS id , ju.name AS name , ju.username AS
username , ju.email AS email , IFNULL(vmu.user_is_vendor,"0") AS is_vendor , IFNULL(sg.shopper_group_name, "") AS shopper_group_name FROM tsaga_users
AS ju LEFT JOIN tsaga_virtuemart_vmusers AS vmu ON ju.id = vmu.virtuemart_user_id LEFT JOIN tsaga_virtuemart_vmuser_shoppergroups AS vx ON ju.id =
vx.virtuemart_user_id LEFT JOIN tsaga_virtuemart_shoppergroups AS sg ON vx.virtuemart_shoppergroup_id = sg.virtuemart_shoppergroup_id GROUP BY ju.id
ORDER BY virtuemart_user_id ASC LIMIT 0, 30


VM 3.0.7.2
JM 3.4.1
Title: Re: Shoppers error VM 3.0.7.2 JM 3.4.1
Post by: thewitt on April 12, 2015, 09:19:37 AM
It can be corrected by simply changing the ORDER BY clause to be

ORDER BY vmu.virtuemart_user_id

but i can't figure out where to change this... Still digging.
Title: Re: Shoppers error VM 3.0.7.2 JM 3.4.1
Post by: Milbo on April 12, 2015, 09:51:44 AM
So when you are in the BE? The list does not allow to sort by ids, actually. At least not in j2.5. I wonder how you get this query. Anyway is almost fixed.

If you wonder how. Check the constructor of the user model.
Title: Re: Shoppers error VM 3.0.7.2 JM 3.4.1
Post by: thewitt on April 12, 2015, 09:53:42 AM
The more I look at this, I think it should just be:

ORDER BY id

and I can't see where it broke....  but it does look like it's broken and should not be using virtuemart_user_id in the order clause at all.
Title: Re: Shoppers error VM 3.0.7.2 JM 3.4.1
Post by: thewitt on April 12, 2015, 09:54:19 AM
This is the DEFAULT order by clause in the query, and I think it's incorrect and should simply be ID
Title: Re: Shoppers error VM 3.0.7.2 JM 3.4.1
Post by: Milbo on April 12, 2015, 09:57:04 AM
Hmmm, I just wanted to post my solution

$this->setToggleName('user_is_vendor');
$this->addvalidOrderingFieldName(array('ju.username','ju.name','sg.virtuemart_shoppergroup_id','shopper_group_name','shopper_group_desc','vmu.virtuemart_user_id') );
$this->setMainTable('vmusers');
$this->removevalidOrderingFieldName('virtuemart_user_id');
array_unshift($this->_validOrderingFieldName,'ju.id');


But you are right. If we want to sort also users who are only joomla users and not already vmusers, then we should use id.
Title: Re: Shoppers error VM 3.0.7.2 JM 3.4.1
Post by: Milbo on April 12, 2015, 09:59:01 AM
The code above is the same. Just use in the BE user view, default.php line 65


<th><?php echo $this->sort('ju.id''COM_VIRTUEMART_ID'?></th>


Thank you for reporting
Title: Re: Shoppers error VM 3.0.7.2 JM 3.4.1
Post by: thewitt on April 12, 2015, 10:07:31 AM
Thank you !
Title: Re: Shoppers error VM 3.0.7.2 JM 3.4.1
Post by: Milbo on April 12, 2015, 10:12:38 AM
Just for explanation, the

array_unshift($this->_validOrderingFieldName,'ju.id');


Sets the ordering ju.id as the default.
Title: Re: Shoppers error VM 3.0.7.2 JM 3.4.1
Post by: thewitt on April 12, 2015, 10:58:54 AM
Sorry. It did not make any difference. I'm trying now to understand why.
Title: Re: Shoppers error VM 3.0.7.2 JM 3.4.1
Post by: thewitt on April 12, 2015, 11:07:12 AM
Just a typo... thank you
Title: Re: Shoppers error VM 3.0.7.2 JM 3.4.1
Post by: thewitt on April 12, 2015, 11:10:14 AM
Can you see any reason NOT to add Sort by Email to this screen in default.php?

<th width="25%"><?php echo $this->sort('ju.email''COM_VIRTUEMART_EMAIL'); ?></th>

Seems to make it more complete to me.

I needed to add ju.email to the constructor too, but it seems to work fine.
Title: Re: Shoppers error VM 3.0.7.2 JM 3.4.1
Post by: Milbo on April 12, 2015, 12:25:18 PM
yeh, why not. Added.