public function index($id = 0, $params = array())
 {
     $lang_code = $this->safeGet($params, 'lang_code', DEFAULT_LANGUAGE);
     if (!empty($id)) {
         $data = fn_get_category_data($id, $lang_code);
         if (empty($data)) {
             $status = Response::STATUS_NOT_FOUND;
         } else {
             $status = Response::STATUS_OK;
         }
     } else {
         if (!empty($params['category_ids']) && is_array($params['category_ids'])) {
             $params['item_ids'] = $params['category_ids'];
         }
         $params['plain'] = $this->safeGet($params, 'plain', true);
         $params['simple'] = $this->safeGet($params, 'simple', false);
         $params['group_by_level'] = $this->safeGet($params, 'group_by_level', false);
         $items_per_page = $this->safeGet($params, 'items_per_page', Registry::get('settings.Appearance.admin_products_per_page'));
         $page = $this->safeGet($params, 'page', 1);
         list($data, $params) = fn_get_categories($params, $lang_code);
         $params['items_per_page'] = $items_per_page;
         $params['page'] = $page;
         $params['total_items'] = count($data);
         if ($items_per_page) {
             $data = array_slice($data, ($page - 1) * $items_per_page, $items_per_page);
         }
         $data = array('categories' => $data, 'params' => $params);
         $status = Response::STATUS_OK;
     }
     return array('status' => $status, 'data' => $data);
 }
Beispiel #2
0
function fn_se_get_categories_data($categories_ids = array(), $company_id = 0, $lang_code)
{
    list($categories, ) = fn_get_categories(array('plain' => true, 'simple' => false, 'status' => 'A', 'item_ids' => join(',', $categories_ids), 'group_by_level' => false), $lang_code);
    $data = array();
    $categories_ids = fn_se_get_ids($categories, 'category_id');
    $categories_data = db_get_hash_array("SELECT c.category_id, cd.description FROM ?:categories AS c LEFT JOIN ?:category_descriptions AS cd ON cd.category_id = c.category_id AND cd.lang_code = ?s WHERE c.category_id IN (?n)", 'category_id', $lang_code, $categories_ids);
    foreach ($categories as &$category) {
        $category_id = $category['category_id'];
        if (!isset($categories_data[$category_id])) {
            $categories_data[$category_id] = array();
        }
        $category = array_merge($category, array('description' => ''), $categories_data[$category_id]);
        $data[] = array('id' => $category['category_id'], 'parent_id' => $category['parent_id'], 'link' => fn_url('categories.view?category_id=' . $category['category_id'], 'C', 'http', $lang_code), 'title' => $category['category'], 'summary' => $category['description']);
    }
    return $data;
}
Beispiel #3
0
 protected function getVisibleCategories()
 {
     $visible_categories = null;
     if (!isset($visible_categories)) {
         $visible_categories = array();
         if ($this->options['disable_cat_d'] == "Y") {
             $params['plain'] = true;
             $params['status'] = array('A', 'H');
             list($categories_tree, ) = fn_get_categories($params);
             if (!empty($categories_tree)) {
                 foreach ($categories_tree as $value) {
                     if (isset($value['category_id'])) {
                         $visible_categories[] = $value['category_id'];
                     }
                 }
             }
         }
     }
     return $visible_categories;
 }
Beispiel #4
0
         $params['extend'][] = 'sharing';
     }
     list($fields, $join, $condition) = fn_get_products($params);
     db_query('SELECT SQL_CALC_FOUND_ROWS ' . implode(', ', $fields) . ' FROM ?:products AS products' . $join . ' WHERE 1 ' . $condition . ' GROUP BY products.product_id');
     $general_stats['products']['out_of_stock_products'] = db_get_found_rows();
 }
 /* Customers */
 if (fn_check_view_permissions('profiles.manage', 'GET')) {
     $general_stats['customers'] = array();
     $users_company_condition = fn_get_company_condition('?:users.company_id');
     $general_stats['customers']['registered_customers'] = db_get_field('SELECT COUNT(*) FROM ?:users WHERE user_type = ?s ?p', 'C', $users_company_condition);
 }
 /* Categories */
 if (fn_check_view_permissions('categories.manage', 'GET')) {
     $general_stats['categories'] = array();
     list($fields, $join, $condition, $group_by, $sorting, $limit) = fn_get_categories(array('get_conditions' => true));
     $general_stats['categories']['total_categories'] = db_get_field('SELECT COUNT(*) FROM ?:categories WHERE 1 ?p', $condition);
 }
 /* Storefronts */
 if (fn_check_view_permissions('companies.manage', 'GET')) {
     $general_stats['companies'] = array();
     if (Registry::get('runtime.company_id')) {
         $general_stats['companies']['total_companies'] = 1;
     } else {
         $general_stats['companies']['total_companies'] = db_get_field('SELECT COUNT(*) FROM ?:companies');
     }
 }
 /* Pages */
 if (fn_check_view_permissions('pages.manage', 'GET')) {
     $general_stats['pages'] = array();
     list($fields, $join, $condition) = fn_get_pages(array('get_conditions' => true));
Beispiel #5
0
                fn_add_breadcrumb($cats[$c_id], "categories.view?category_id={$c_id}");
            }
        }
        fn_add_breadcrumb($category_data['category'], empty($_REQUEST['features_hash']) ? '' : "categories.view?category_id={$_REQUEST['category_id']}");
        // [/Breadcrumbs]
    } else {
        return array(CONTROLLER_STATUS_NO_PAGE);
    }
} elseif ($mode == 'picker') {
    $category_count = db_get_field("SELECT COUNT(*) FROM ?:categories");
    if ($category_count < CATEGORY_THRESHOLD) {
        $params = array('simple' => false);
        list($categories_tree, ) = fn_get_categories($params);
        Tygh::$app['view']->assign('show_all', true);
    } else {
        $params = array('category_id' => $_REQUEST['category_id'], 'current_category_id' => $_REQUEST['category_id'], 'visible' => true, 'simple' => false);
        list($categories_tree, ) = fn_get_categories($params);
    }
    if (!empty($_REQUEST['root'])) {
        array_unshift($categories_tree, array('category_id' => 0, 'category' => $_REQUEST['root']));
    }
    Tygh::$app['view']->assign('categories_tree', $categories_tree);
    if ($category_count < CATEGORY_SHOW_ALL) {
        Tygh::$app['view']->assign('expand_all', true);
    }
    if (defined('AJAX_REQUEST')) {
        Tygh::$app['view']->assign('category_id', $_REQUEST['category_id']);
    }
    Tygh::$app['view']->display('pickers/categories/picker_contents.tpl');
    exit;
}
Beispiel #6
0
        Tygh::$app['view']->assign('categories_stats', fn_get_categories_stats());
    }
    $category_count = db_get_field("SELECT COUNT(*) FROM ?:categories");
    $category_id = empty($_REQUEST['category_id']) ? 0 : $_REQUEST['category_id'];
    $except_id = 0;
    if (!empty($_REQUEST['except_id'])) {
        $except_id = $_REQUEST['except_id'];
        Tygh::$app['view']->assign('except_id', $_REQUEST['except_id']);
    }
    if ($category_count < CATEGORY_THRESHOLD) {
        $params = array('simple' => false, 'add_root' => !empty($_REQUEST['root']) ? $_REQUEST['root'] : '', 'b_id' => !empty($_REQUEST['b_id']) ? $_REQUEST['b_id'] : '', 'except_id' => $except_id, 'company_ids' => !empty($_REQUEST['company_ids']) ? $_REQUEST['company_ids'] : '', 'save_view_results' => !empty($_REQUEST['save_view_results']) ? $_REQUEST['save_view_results'] : '');
        list($categories_tree, ) = fn_get_categories($params, DESCR_SL);
        Tygh::$app['view']->assign('show_all', true);
    } else {
        $params = array('category_id' => $category_id, 'current_category_id' => $category_id, 'visible' => true, 'simple' => false, 'add_root' => !empty($_REQUEST['root']) ? $_REQUEST['root'] : '', 'b_id' => !empty($_REQUEST['b_id']) ? $_REQUEST['b_id'] : '', 'except_id' => $except_id, 'company_ids' => !empty($_REQUEST['company_ids']) ? $_REQUEST['company_ids'] : '', 'save_view_results' => !empty($_REQUEST['save_view_results']) ? $_REQUEST['save_view_results'] : '');
        list($categories_tree, ) = fn_get_categories($params, DESCR_SL);
    }
    Tygh::$app['view']->assign('categories_tree', $categories_tree);
    if ($category_count < CATEGORY_SHOW_ALL) {
        Tygh::$app['view']->assign('expand_all', true);
    }
    if (defined('AJAX_REQUEST')) {
        if (!empty($_REQUEST['random'])) {
            Tygh::$app['view']->assign('random', $_REQUEST['random']);
        }
        Tygh::$app['view']->assign('category_id', $category_id);
    }
}
//
// Categories picker
//
Beispiel #7
0
function fn_twg_api_get_categories($params, $lang_code = CART_LANGUAGE)
{
    $params['get_images'] = 'Y';
    $category_id = !empty($params['id']) ? $params['id'] : 0;
    $type = !empty($params['type']) ? $params['type'] : '';
    if ($type == 'one_level') {
        $type_params = array('category_id' => $category_id, 'current_category_id' => $category_id, 'simple' => false, 'visible' => true);
    } elseif ($type == 'plain_tree') {
        $type_params = array('category_id' => $category_id, 'current_category_id' => $category_id, 'simple' => false, 'visible' => false, 'plain' => true);
    } else {
        $type_params = array('simple' => false, 'category_id' => $category_id, 'current_category_id' => $category_id);
    }
    $params = array_merge($type_params, $params);
    list($categories, ) = fn_get_categories($params, $lang_code);
    $image_params = TwigmoSettings::get('images.catalog');
    foreach ($categories as $k => $v) {
        if (!empty($v['has_children'])) {
            $categories[$k]['subcategory_count'] = db_get_field("SELECT COUNT(*) FROM ?:categories WHERE parent_id = ?i", $v['category_id']);
        }
        if (!empty($params['get_images']) && !empty($v['main_pair'])) {
            $categories[$k]['icon'] = TwigmoImage::getApiImageData($v['main_pair'], 'category', 'icon', $image_params);
        }
    }
    $result = Api::getAsList('categories', $categories);
    return $result;
}
Beispiel #8
0
function fn_yml_get_categories_ids($category_id = 0, $status = array('A'))
{
    $categories_ids = array();
    $categories_data = array();
    $params['plain'] = true;
    $params['status'] = $status;
    $params['category_id'] = $category_id;
    $params['current_category_id'] = $category_id;
    list($categories, ) = fn_get_categories($params, DESCR_SL);
    if (!empty($categories)) {
        foreach ($categories as $category) {
            if (isset($category['category_id'])) {
                $categories_ids[] = $category['category_id'];
                $categories_data[$category['category_id']] = $category;
            }
        }
    }
    return array($categories_ids, $categories_data);
}
Beispiel #9
0
//
if ($mode == 'get_product') {
    $_REQUEST['product_id'] = empty($_REQUEST['product_id']) ? 0 : $_REQUEST['product_id'];
    $product = fn_get_product_data($_REQUEST['product_id'], $auth, CART_LANGUAGE);
    if (!empty($product)) {
        if (!empty($_REQUEST['combination'])) {
            $product['combination'] = $combination;
        }
        fn_gather_additional_product_data($product, true, true);
        $xml .= fn_array_to_xml($product, 'product_data');
    }
}
if ($mode == 'get_categories') {
    $_REQUEST['category_id'] = empty($_REQUEST['category_id']) ? 0 : $_REQUEST['category_id'];
    $params = array('category_id' => $_REQUEST['category_id'], 'visible' => false, 'plain' => !empty($_REQUEST['format']) && $_REQUEST['format'] == 'plain' ? true : false);
    list($categories, ) = fn_get_categories($params, CART_LANGUAGE);
    $xml .= fn_array_to_xml($categories, 'categories');
}
if ($mode == 'get_category') {
    $_REQUEST['category_id'] = empty($_REQUEST['category_id']) ? 0 : $_REQUEST['category_id'];
    $category_data = fn_get_category_data($_REQUEST['category_id'], '*');
    if (!empty($category_data)) {
        $xml .= fn_array_to_xml($category_data, 'category_data');
    }
}
echo $xml;
exit;
function fn_array_to_xml(&$array, $name)
{
    $xml = "<{$name}>";
    $subname = 'item';
Beispiel #10
0
 if (empty($product_data)) {
     return array(CONTROLLER_STATUS_NO_PAGE);
 }
 list($product_features, $features_search) = fn_get_paginated_product_features(array('product_id' => $product_data['product_id']), $auth, $product_data, DESCR_SL);
 Tygh::$app['view']->assign('product_features', $product_features);
 Tygh::$app['view']->assign('features_search', $features_search);
 $taxes = fn_get_taxes();
 arsort($product_data['category_ids']);
 if (fn_allowed_for('MULTIVENDOR')) {
     // reload form (refresh categories list if vendor was changed)
     if (defined('AJAX_REQUEST') && !empty($_REQUEST['reload_form'])) {
         $company_id = isset($_REQUEST['product_data']['company_id']) ? $_REQUEST['product_data']['company_id'] : 0;
         $company_data = fn_get_company_data($company_id);
         if (!empty($company_data['categories'])) {
             $params = array('simple' => false, 'company_ids' => $company_id);
             list($cat_ids, ) = fn_get_categories($params);
             $cat_ids = array_keys($cat_ids);
             //Assign available category ids to be displayed after admin changes product owner.
             $product_data['category_ids'] = array_intersect($product_data['category_ids'], $cat_ids);
         }
         //Assign received company_id to product data for the correct company categories to be displayed in the picker.
         $product_data['company_id'] = $company_id;
         Tygh::$app['view']->assign('product_data', $product_data);
         Tygh::$app['view']->display('views/products/update.tpl');
         exit;
     }
 }
 Tygh::$app['view']->assign('product_data', $product_data);
 Tygh::$app['view']->assign('taxes', $taxes);
 $product_options = fn_get_product_options($_REQUEST['product_id'], DESCR_SL);
 if (!empty($product_options)) {
/**
 * Gets categefories and products totals data
 *
 * @return array Array with categories and products totals
 */
function fn_get_categories_stats()
{
    $stats = array();
    $params = array('only_short_fields' => true, 'extend' => array('companies', 'sharing'), 'get_conditions' => true);
    list($fields, $join, $condition) = fn_get_products($params);
    db_query('SELECT SQL_CALC_FOUND_ROWS 1 FROM ?:products AS products' . $join . ' WHERE 1 ' . $condition . 'GROUP BY products.product_id');
    $stats['products_total'] = db_get_found_rows();
    $params = array('get_conditions' => true);
    list($fields, $join, $condition, $group_by, $sorting, $limit) = fn_get_categories($params);
    $stats['categories_total'] = db_get_field('SELECT COUNT(*) FROM ?:categories WHERE 1 ?p', $condition);
    $params = array('get_conditions' => true, 'status' => 'A');
    list($fields, $join, $condition, $group_by, $sorting, $limit) = fn_get_categories($params);
    $stats['categories_active'] = db_get_field('SELECT COUNT(*) FROM ?:categories WHERE 1 ?p', $condition);
    $params = array('get_conditions' => true, 'status' => 'H');
    list($fields, $join, $condition, $group_by, $sorting, $limit) = fn_get_categories($params);
    $stats['categories_hidden'] = db_get_field('SELECT COUNT(*) FROM ?:categories WHERE 1 ?p', $condition);
    $params = array('get_conditions' => true, 'status' => 'D');
    list($fields, $join, $condition, $group_by, $sorting, $limit) = fn_get_categories($params);
    $stats['categories_disabled'] = db_get_field('SELECT COUNT(*) FROM ?:categories WHERE 1 ?p', $condition);
    return $stats;
}
Beispiel #12
0
function fn_get_vendor_categories($params)
{
    $items = array();
    if (!empty($params['company_ids'])) {
        $items = fn_get_categories($params);
    }
    return $items;
}
Beispiel #13
0
function fn_mailru_get_visible_categories($addon_settings)
{
    $visible_categories = null;
    if (!isset($visible_categories)) {
        $visible_categories = array();
        if ($addon_settings['disable_cat_d'] == "Y") {
            $params['plain'] = true;
            $params['status'] = array('A', 'H');
            list($categories_tree, ) = fn_get_categories($params);
            if (!empty($categories_tree)) {
                foreach ($categories_tree as $value) {
                    if (isset($value['category_id'])) {
                        $visible_categories[] = $value['category_id'];
                    }
                }
            }
        }
    }
    return $visible_categories;
}
Beispiel #14
0
 protected function buildCategories(&$yml2_data)
 {
     $params = array('simple' => false, 'plain' => true);
     list($categories_tree, ) = fn_get_categories($params, $this->lang_code);
     if (!empty($this->options['hidden_categories_data'])) {
         foreach ($this->options['hidden_categories_data'] as $category_id => $category_data) {
             $categories_tree[] = $category_data;
         }
     }
     foreach ($categories_tree as $cat) {
         if (isset($cat['category_id']) && in_array($cat['category_id'], $this->export_category_ids) && !in_array($cat['category_id'], $this->exclude_category_ids)) {
             if ($cat['parent_id'] == 0) {
                 $yml2_data['categories']['category@id=' . $cat['category_id']] = $cat['category'];
             } else {
                 $yml2_data['categories']['category@id=' . $cat['category_id'] . '@parentId=' . $cat['parent_id']] = $cat['category'];
             }
         }
     }
 }
Beispiel #15
0
function fn_get_plain_categories_tree($category_id = '0', $simple = true, $lang_code = CART_LANGUAGE)
{
    $params = array('category_id' => $category_id, 'simple' => $simple, 'visible' => false, 'plain' => true);
    list($categories, ) = fn_get_categories($params, $lang_code);
    return $categories;
}