dolibarr  13.0.2
getCombinations.php
1 <?php
2 
3 /* Copyright (C) 2016 Marcos GarcĂ­a <marcosgdf@gmail.com>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <https://www.gnu.org/licenses/>.
17  */
18 
19 if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1');
20 if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
21 if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1');
22 if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
23 if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1');
24 
25 require '../../main.inc.php';
26 require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
27 require_once DOL_DOCUMENT_ROOT.'/variants/class/ProductCombination.class.php';
28 
29 header('Content-Type: application/json');
30 
31 $id = GETPOST('id', 'int');
32 
33 if (!$id) {
34  print json_encode(array(
35  'error' => 'ID not set'
36  ));
37  exit();
38 }
39 
40 $product = new Product($db);
41 
42 if ($product->fetch($id) < 0) {
43  print json_encode(array(
44  'error' => 'Product not found'
45  ));
46 }
47 
48 $prodcomb = new ProductCombination($db);
49 
50 echo json_encode($prodcomb->getUniqueAttributesAndValuesByFkProductParent($product->id));
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class to manage products or services.
Class ProductCombination Used to represent a product combination.
print
Draft customers invoices.
Definition: index.php:89