Author Topic: Do not Display Product, if child products also out of stock’ is chosen & Top 10  (Read 3190 times)

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 10688
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.8.8
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
GJC Web Design
VirtueMart and Joomla Developers - php developers
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
Contact for any VirtueMart or Joomla development & customisation


  • Beginner
  • *
  • Posts: 14
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.


  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 10530
  • VM4.0.7 Eagle Owl
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
thx, fixed.
Should I fix your bug, please support the VirtueMart project and become a member
Extensions approved by the core team: