diff --git a/modules/EcmProducts/EcmProduct.php b/modules/EcmProducts/EcmProduct.php index 012de61d..56ecc72c 100755 --- a/modules/EcmProducts/EcmProduct.php +++ b/modules/EcmProducts/EcmProduct.php @@ -624,6 +624,25 @@ class EcmProduct extends SugarBean } return false; } + function getProductUsingComponent() + { + $db = $GLOBALS['db']; + $res = $db->query(" + SELECT p.code, pc.quantity +FROM ecmproductcomponents AS pc +INNER JOIN ecmproducts AS p +ON p.id = pc.ecmproduct_id +WHERE ecmcomponent_id='$this->id'; + "); + $products = array(); + while ($row = $db->fetchByAssoc($res)) { + $products[] = array( + 'code' => $row['code'], + 'quantity' => $row['quantity'], + ); + } + return $products; + } //***************************Start Managing Positions*************************// function constructInsertQuery($data, $table = '') {