HEX
Server: Apache/2.4.6 (CentOS) mpm-itk/2.4.7-04 mod_fcgid/2.3.9 PHP/5.4.16
System: Linux dvm.vladweb.ru 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
User: region-gk.ru (1016)
PHP: 7.3.33
Disabled: NONE
Upload Files
File: /home/temp/yarusvl.ru/adminx/ajax/get_features.php
<?php

    if(!$mgc->managers->access('products')) {
        exit();
    }

    /*Принимаем данные о товаре и категории*/
    $category_id = $mgc->request->get('category_id', 'integer');
    $product_id = $mgc->request->get('product_id', 'integer');
    if(!empty($category_id)) {
        $features = $mgc->features->get_features(array('category_id'=>$category_id));
    } else {
        $features = $mgc->features->get_features();
    }

    /*Выборка значений свойств*/
    $options = array();
    if(!empty($product_id)) {
        $opts = $mgc->features->get_product_options(array('product_id'=>$product_id));
        foreach($opts as $opt) {
            $options[$opt->feature_id] = $opt;
        }
    }
    
    foreach($features as $f) {
        if(isset($options[$f->id])) {
            $f->value = $options[$f->id]->value;
            $f->translit = $options[$f->id]->translit;
        } else {
            $f->value = '';
            $f->translit = '';
        }
    }
    
    header("Content-type: application/json; charset=UTF-8");
    header("Cache-Control: must-revalidate");
    header("Pragma: no-cache");
    header("Expires: -1");
    print json_encode($features);