News:

Looking for documentation? Take a look on our wiki

Main Menu

Probably wrong query for Child Products

Started by vinceferro, February 10, 2012, 14:49:40 PM

Previous topic - Next topic

vinceferro

Hi there!
Looking in VirtueMart source code i've founded this function in: "administrator/components/com_virtuemart/models/product.php"

   /**
    * Check if the product has any children
    *
    * @author RolandD
    * @author MaxMilbers
    * @param int $virtuemart_product_id Product ID
    * @return bool True if there are child products, false if there are no child products
    */
   public function checkChildProducts($virtuemart_product_id) {

      $q  = 'SELECT IF(COUNT(virtuemart_product_id) > 0, "0", "1") FROM `#__virtuemart_products` WHERE `product_parent_id` = "'.(int)$virtuemart_product_id.'"';
      $this->_db->setQuery($q);

      return $this->_db->loadResult();

   }
I think the return value is incorrect, in fact it is 0 if the children count is higher than 0.
Is it an expected behavior?


Milbo

Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/