CMXX - Added categories filter for commerce

This commit is contained in:
“VeLiTi”
2025-02-04 11:46:14 +01:00
parent 59c23bf46c
commit 0172f8405a
5 changed files with 127 additions and 5 deletions

View File

@@ -10,12 +10,42 @@ defined($security_key) or exit;
//------------------------------------------
$catalog = []; // Main catalog array
//NEW ARRAY
$criterias = [];
$filter = '';
//Check for $_GET variables and build $_GET
if(isset($get_content) && $get_content!=''){
//GET VARIABLES FROM URL
$requests = explode("&", $get_content);
//Check for keys and values
foreach ($requests as $y){
$v = explode("=", $y);
//INCLUDE VARIABLES IN ARRAY
$criterias[$v[0]] = $v[1];
if ($v[0] == 'category'){
//------------------------------------------
//IF CATEGORY IS RECEIVED ONLY GET RELATED PRODUCTS
//------------------------------------------
$url_input = '';
//Get all the related products from the database
$cat_products = ioAPIv2('/v2/products_categories/list=filter&category_id='.$v[1],'',$clientsecret);
$cat_products = json_decode($cat_products,true);
foreach($cat_products as $cat_product_id){
$url_input .= $cat_product_id['product_id'].',';
}
$filter .= '&product_id='.substr($url_input,0,-1);
}
}
}
//------------------------------------------
//GET ACTIVE AND SALES RELATED PRODUCTS
//------------------------------------------
$filter = (isset($get_content) && $get_content !='') ? '&'.$get_content : '';
//GET PRODUCTS
$api_url = '/v2/products/salesflag=1&status=1'.$filter;
$products = ioApi($api_url,'',$clientsecret);