function fn_seo_update_product_categories_post($product_id, $product_data, $existing_categories, $rebuild) { if ($rebuild == true) { $company_ids = array(!empty($product_data['company_id']) ? $product_data['company_id'] : 0); if (fn_allowed_for('ULTIMATE') && !Registry::get('runtime.company_id')) { $company_ids = fn_ult_get_shared_product_companies($product_id); } foreach ($company_ids as $company_id) { fn_seo_update_tree_object($product_id, 'p', array('company_id' => $company_id, 'object_types' => array('p'))); } return true; } return false; }
/** * Shares product option among the companies for which the given product is shared. * * @param int $option_id Option identifier * @param int $product_id Product identifier */ function fn_ult_share_product_option($option_id, $product_id) { $product_company_ids = fn_ult_get_shared_product_companies($product_id); foreach ($product_company_ids as $product_company_id) { fn_ult_update_share_object($option_id, 'product_options', $product_company_id); } }
function fn_get_ebay_templates($params, $items_per_page = 0, $lang_code = CART_LANGUAGE, $get_simple = false) { // Init filter $params = LastView::instance()->update('ebay_templates', $params); $fields = array('templates.template_id', 'templates.status', 'descr.name', 'templates.company_id'); // Define sort fields $sortings = array('status' => 'templates.status', 'name' => 'descr.name'); $condition = ''; //fn_get_company_condition('templates.company_id') $join = db_quote('LEFT JOIN ?:ebay_template_descriptions as descr ON templates.template_id = descr.template_id AND descr.lang_code = ?s', $lang_code); if (!empty($params['product_id'])) { if (fn_allowed_for('ULTIMATE')) { if (Registry::get('runtime.simple_ultimate')) { $condition = ''; } else { $company_ids = fn_ult_get_shared_product_companies($params['product_id']); $tempalte_ids = db_get_fields("SELECT share_object_id FROM ?:ult_objects_sharing WHERE share_object_type = 'ebay_templates' AND share_company_id IN (?n)", $company_ids); $condition = db_quote(' AND templates.template_id IN (?n)', $tempalte_ids); } } elseif (fn_allowed_for('MULTIVENDOR')) { if (Registry::get('runtime.company_id')) { $condition = fn_get_company_condition('templates.company_id'); } else { $company_id = db_get_field("SELECT company_id FROM ?:products WHERE product_id = ?i", $params['product_id']); $condition = db_quote(" AND templates.company_id = ?i", $company_id); } } } else { if (fn_allowed_for('ULTIMATE') && !Registry::get('runtime.simple_ultimate') && Registry::get('runtime.company_id')) { $join .= db_quote(" INNER JOIN ?:ult_objects_sharing ON (?:ult_objects_sharing.share_object_id = templates.template_id AND ?:ult_objects_sharing.share_company_id = ?i AND ?:ult_objects_sharing.share_object_type = 'ebay_templates')", Registry::get('runtime.company_id')); } } $limit = ''; $group_by = 'templates.template_id'; // -- SORTINGS -- if (empty($params['sort_by']) || empty($sortings[$params['sort_by']])) { $params['sort_by'] = 'name'; } if (empty($params['sort_order'])) { $params['sort_order'] = 'asc'; } $sorting = db_sort($params, $sortings); if (!empty($params['limit'])) { $limit = db_quote(" LIMIT 0, ?i", $params['limit']); } elseif (!empty($params['items_per_page'])) { $limit = db_paginate($params['page'], $params['items_per_page']); } Registry::set('runtime.skip_sharing_selection', true); $templates = db_get_array("SELECT SQL_CALC_FOUND_ROWS " . implode(', ', $fields) . " FROM ?:ebay_templates as templates {$join} WHERE 1 {$condition} GROUP BY {$group_by} {$sorting} {$limit}"); Registry::set('runtime.skip_sharing_selection', false); if (!empty($params['items_per_page'])) { $params['total_items'] = !empty($total) ? $total : db_get_found_rows(); } else { $params['total_items'] = count($templates); } if ($get_simple == true) { $_templates = array(); foreach ($templates as $template) { $_templates[$template['template_id']] = $template['name']; } return $_templates; } return array($templates, $params); }
} return $cache[$object_id]; }, 'parent_type' => 'c', 'name' => 'category', 'picker' => 'pickers/categories/picker.tpl', 'picker_params' => array('multiple' => false, 'use_keys' => 'N'), 'table' => '?:category_descriptions', 'description' => 'category', 'dispatch' => 'categories.view', 'item' => 'category_id', 'condition' => '', 'not_shared' => true, 'tree_options' => array('category', 'category_nohtml'), 'html_options' => array('file', 'category'), 'pager' => true, 'option' => 'seo_category_type', 'exist_function' => function ($category_id) { return fn_category_exists($category_id); }), 'p' => array('tree' => true, 'path_function' => function ($object_id, $company_id = 0) { static $cache = array(); if (!isset($cache[$company_id][$object_id])) { $path = db_get_hash_single_array("SELECT c.id_path, p.link_type FROM ?:categories as c LEFT JOIN ?:products_categories as p ON p.category_id = c.category_id WHERE p.product_id = ?i ?p", array('link_type', 'id_path'), $object_id, fn_get_seo_company_condition('c.company_id', '', $company_id)); $cache[$company_id][$object_id] = !empty($path['M']) ? $path['M'] : $path['A']; } return $cache[$company_id][$object_id]; }, 'parent_type' => 'c', 'name' => 'product', 'picker' => 'pickers/products/picker.tpl', 'picker_params' => array('type' => 'single', 'view_mode' => 'button'), 'table' => '?:product_descriptions', 'description' => 'product', 'dispatch' => 'products.view', 'item' => 'product_id', 'condition' => '', 'not_shared' => true, 'tree_options' => array('product_category_nohtml', 'product_category'), 'html_options' => array('product_category', 'product_file'), 'option' => 'seo_product_type', 'exist_function' => function ($product_id, $company_id) { $result = fn_product_exists($product_id); // Check whether product is shared for given company if ($result && fn_allowed_for('ULTIMATE')) { $result = $result && in_array($company_id, fn_ult_get_shared_product_companies($product_id)); } return $result; }), 'a' => array('tree' => true, 'path_function' => function ($object_id) { static $cache = array(); if (!isset($cache[$object_id])) { $path = db_get_field("SELECT id_path FROM ?:pages WHERE page_id = ?i", $object_id); $apath = explode('/', $path); array_pop($apath); $cache[$object_id] = implode('/', $apath); } return $cache[$object_id]; }, 'parent_type' => 'a', 'name' => 'page', 'picker' => 'pickers/pages/picker.tpl', 'picker_params' => array('multiple' => false, 'use_keys' => 'N'), 'table' => '?:page_descriptions', 'description' => 'page', 'dispatch' => 'pages.view', 'item' => 'page_id', 'condition' => '', 'tree_options' => array('page', 'page_nohtml'), 'html_options' => array('file', 'page'), 'pager' => true, 'option' => 'seo_page_type', 'exist_function' => function ($page_id) { return fn_page_exists($page_id); }), 'e' => array('table' => '?:product_feature_variant_descriptions', 'description' => 'variant', 'dispatch' => 'product_features.view', 'item' => 'variant_id', 'condition' => '', 'name' => 'feature', 'html_options' => array('file'), 'option' => 'seo_other_type'), 's' => array('table' => '?:seo_names', 'description' => 'name', 'dispatch' => '', 'item' => 'object_id', 'condition' => fn_get_seo_company_condition('?:seo_names.company_id'), 'not_shared' => true, 'name' => 'custom', 'html_options' => array('file'), 'option' => 'seo_other_type')); if (fn_allowed_for('MULTIVENDOR')) {