CMXX - Categories and filters

This commit is contained in:
“VeLiTi”
2025-02-03 11:28:05 +01:00
parent 754359f6b6
commit 59c23bf46c
15 changed files with 688 additions and 9 deletions

View File

@@ -53,12 +53,30 @@ elseif ($command == 'insert'){
$post_content['created'] = $date;
$post_content['createdby'] = $username;
$post_content['accounthierarchy'] = $partner_product;
}
else {
//do nothing
}
//CREAT NEW ARRAY AND MAP TO CLAUSE
//CHECK IF CATEGORIES ARE SEND AND UPDATE
if (isset($post_content['categories'])){
if ($command != 'insert'){
//CHANGE OR DELETE SO PRODUCT_ID IS AVAILABLE IN CALL
$api_url = '/v2/products_categories/';
$data = json_encode(array("categories" => $post_content['categories'], "product_id" => $id), JSON_UNESCAPED_UNICODE);
$responses = ioApiv2($api_url,$data,$clientsecret);
} else {
//INSERT Product ROWID NOT AVAILABLE YET. store $post_content['categories'] in different variable.
$categories = $post_content['categories'];
}
//REMOVE CATERGORIES FROM POST_CONTENT ARRAY
unset($post_content['categories']);
}
//CREATe NEW ARRAY AND MAP TO CLAUSE
if(isset($post_content) && $post_content!=''){
foreach ($post_content as $key => $var){
if ($key == 'submit' || $key == 'rowID'){
@@ -90,6 +108,11 @@ elseif ($command == 'insert' && isAllowed('products',$profile,$permission,'C') =
$sql = 'INSERT INTO products ('.$clause_insert.') VALUES ('.$input_insert.')';
$stmt = $pdo->prepare($sql);
$stmt->execute($execute_input);
$api_url = '/v2/products_categories/';
$data = json_encode(array("categories" => $categories, "product_id" => $id), JSON_UNESCAPED_UNICODE);
$responses = ioApiv2($api_url,$data,$clientsecret);
}
elseif ($command == 'delete' && isAllowed('products',$profile,$permission,'D') === 1){
$stmt = $pdo->prepare('DELETE FROM products WHERE rowID = ? '.$whereclause.'');