VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: GJC Web Design on August 10, 2012, 18:14:46 PM

Title: Do not Display Product, if child products also out of stock’ is chosen & Top 10
Post by: GJC Web Design on August 10, 2012, 18:14:46 PM
This error occurs with the 'Do not Display Product, if child products also out of stock'  chosen  and VM frontpage Top 10 enabled

500 error with Joomla debug on
No Top 10 results when debug off

JDatabaseMySQL::query: 1052 - Column 'product_sales' in order clause is ambiguous

File administrator/components/com_virtuemart/models/product.php around line 404

(@version $Id: product.php 6255 2012-07-11 10:26:02Z Milbo $)(Version 2.0.8e)

When  'Do not Display Product, if child products also out of stock' is chosen in Configuration->ShopFront-> Action when a Product is Out of Stock an extra JOIN is made to the product and search query
LEFT OUTER JOIN `jos_virtuemart_products` children ON p.`virtuemart_product_id` = children.`product_parent_id`

This means there are 2 possible instances now of 'product_sales'  but the WHERE clause is missing a TABLE ALIAS for 'product_sku'  causing the 'Column 'product_sales' in where clause is ambiguous' error.

Original code line 245
$orderBy = ' ORDER BY product_sales ';

Code Added line 245
$orderBy = ' ORDER BY p.product_sales ';


ORDER BY is now

ORDER BY p.product_sales DESC
Title: Re: Do not Display Product, if child products also out of stock’ is chosen & Top 10
Post by: jeoff on August 11, 2012, 01:19:34 AM
to All VM developpers. This is a very real bug that people with a clothing webshop WILL run in to!
See my other topics where I try to explain this situation.

GJC Webdesign solved this issue with high priority for our webshop. I suggest you implement this fix in the next release.
Title: Re: Do not Display Product, if child products also out of stock’ is chosen & Top 10
Post by: Milbo on August 12, 2012, 01:28:34 AM
thx, fixed.