Skip to main content
Post Undeleted by mickmackusa
Ported solution from question to answer
Source Link
mickmackusa
  • 4.9k
  • 4
  • 20
  • 49

I have updated with "solution" to my problem -found the error in my joomla query...

Original:

JOIN mus_virtuemart_product_categories as pc ON pc.virtuemart_product_id=vmp.product_parent_id 

Joomla query:

->join('INNER', $db->quoteName('#__virtuemart_product_categories','pc') . ' ON (' . $db->quoteName('pc.virtuemart_product_id') . ' = ' . $db->quoteName('vmp.virtuemart_product_id') . ')') 
  • The last column reference should be replaced.

Instead of vmp.virtuemart_product_id it should be vmp.product_parent_id

So the final correct query is:

$db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select(array( 'vmp.virtuemart_product_id as product_id', 'vmp.product_parent_id as parent_id', 'vmp.product_sku as sku', 'vmp.product_in_stock as stock', 'vmp.published as published', 'pc.virtuemart_category_id as category' )) ->from($db->quoteName('#__virtuemart_products','vmp')) ->join('INNER', $db->quoteName('#__virtuemart_product_categories','pc') . ' ON (' . $db->quoteName('pc.virtuemart_product_id') . ' = ' . $db->quoteName('vmp.product_parent_id') . ')') ->where($db->quoteName('pc.virtuemart_category_id') . ' = '. $db->quote($category). ' AND '. $db->quoteName('vmp.product_parent_id') . ' >0'); $db->setQuery($query); $podaci = $db->loadAssocList(); 

I have updated with "solution" to my problem - error in my joomla query...

I found the error in my query.

Original:

JOIN mus_virtuemart_product_categories as pc ON pc.virtuemart_product_id=vmp.product_parent_id 

Joomla query:

->join('INNER', $db->quoteName('#__virtuemart_product_categories','pc') . ' ON (' . $db->quoteName('pc.virtuemart_product_id') . ' = ' . $db->quoteName('vmp.virtuemart_product_id') . ')') 
  • The last column reference should be replaced.

Instead of vmp.virtuemart_product_id it should be vmp.product_parent_id

So the final correct query is:

$db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select(array( 'vmp.virtuemart_product_id as product_id', 'vmp.product_parent_id as parent_id', 'vmp.product_sku as sku', 'vmp.product_in_stock as stock', 'vmp.published as published', 'pc.virtuemart_category_id as category' )) ->from($db->quoteName('#__virtuemart_products','vmp')) ->join('INNER', $db->quoteName('#__virtuemart_product_categories','pc') . ' ON (' . $db->quoteName('pc.virtuemart_product_id') . ' = ' . $db->quoteName('vmp.product_parent_id') . ')') ->where($db->quoteName('pc.virtuemart_category_id') . ' = '. $db->quote($category). ' AND '. $db->quoteName('vmp.product_parent_id') . ' >0'); $db->setQuery($query); $podaci = $db->loadAssocList(); 
Post Deleted by mickmackusa
Source Link

I have updated with "solution" to my problem - error in my joomla query...