VirtueMart Forum

VirtueMart 2 + 3 => Virtuemart Development and bug reports => Topic started by: vinceferro on February 10, 2012, 14:49:40 pm

Title: Probably wrong query for Child Products
Post by: vinceferro on February 10, 2012, 14:49:40 pm
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?

Title: Re: Probably wrong query for Child Products
Post by: Milbo on February 11, 2012, 15:32:55 pm
completly deleted as obsolete