} } fn_set_notification('W', __('notice'), __('ebay_addon_used_trial_license', array('[ebay_license_url]' => fn_ebay_get_license_url(), '[days]' => __('ebay_addon_plural_days', array($days))))); } Tygh::$app['view']->assign('templates', $templates); Tygh::$app['view']->assign('search', $search); } elseif ($mode == 'add' || $mode == 'update') { $template_data = array(); if ($mode == 'add') { $template_data = fn_restore_post_data('template_data'); } elseif (!empty($_REQUEST['template_id'])) { $template_data = fn_get_ebay_template($_REQUEST['template_id']); if (empty($template_data)) { return array(CONTROLLER_STATUS_REDIRECT, 'ebay.manage'); } $template_data['product_ids'] = \Ebay\Product::getTemplateProductIds($_REQUEST['template_id']); } if (!isset($template_data['site_id'])) { $template_data['site_id'] = Registry::get('addons.ebay.site_id'); } if (isset($_REQUEST['site_id']) && $template_data['site_id'] != $_REQUEST['site_id']) { $template_data['site_id'] = $_REQUEST['site_id']; if (!defined('AJAX_REQUEST')) { fn_set_notification('N', __('information'), __('ebay_changed_region_message'), 'K'); } } if (isset($_REQUEST['category_id'])) { $template_data['category'] = (int) $_REQUEST['category_id']; } if (isset($_REQUEST['shipping_type'])) { $template_data['shipping_type'] = $_REQUEST['shipping_type'];
<?php /*************************************************************************** * * * (c) 2004 Vladimir V. Kalynyak, Alexey V. Vinokurov, Ilya M. Shalnev * * * * This is commercial software, only users who have purchased a valid * * license and accept to the terms of the License Agreement can install * * and use this program. * * * **************************************************************************** * PLEASE READ THE FULL TEXT OF THE SOFTWARE LICENSE AGREEMENT IN THE * * "copyright.txt" FILE PROVIDED WITH THIS DISTRIBUTION PACKAGE. * ****************************************************************************/ /** * @var string $mode */ use Tygh\Registry; use Tygh\Tygh; if (!defined('BOOTSTRAP')) { die('Access denied'); } if ($mode == 'picker') { $templates = fn_get_ebay_templates(array(), 0, DESCR_SL, true); $statuses = \Ebay\Product::getStatuses(); Tygh::$app['view']->assign('ebay_templates', $templates); Tygh::$app['view']->assign('ebay_product_statuses', $statuses); }
/** * @param $product_ids * @throws \Exception * @throws \SmartyException */ protected static function endProducts(array $product_ids) { static::$count_success = 0; static::$count_fail = 0; static::$count_skip = 0; static::$errors = array(); static::$error_counter = array(); $product_ids = array_filter($product_ids); $templates = $groups = array(); fn_set_progress('parts', count($product_ids)); foreach ($product_ids as $product_id) { $product = new Product($product_id, array('external')); if (empty($product->external_id) || $product->statusIsClosed()) { if (empty($product->external_id)) { static::setError('100_' . $product_id, __('ebay_product_not_exported', array('[product]' => $product->original_title)), true); } else { static::setError('101_' . $product_id, __('ebay_product_already_sales_closed', array('[product]' => $product->original_title)), true); } fn_set_progress('echo', '.'); static::$count_skip++; continue; } if (!isset($templates[$product->template_id])) { $templates[$product->template_id] = $product->getTemplate(); } $groups[$product->template_id][] = $product; if (count($groups[$product->template_id]) >= static::MAX_COUNT_END_PRODUCTS) { static::endGroupProducts($templates[$product->template_id], $groups[$product->template_id]); unset($groups[$product->template_id]); } } if (!empty($groups)) { foreach ($groups as $template_id => $products) { static::endGroupProducts($templates[$template_id], $products); } } /** @var \Smarty $smarty */ $smarty = Tygh::$app['view']; $smarty->assign('end_result', array('count_success' => static::$count_success, 'count_fail' => static::$count_fail, 'count_skip' => static::$count_skip, 'errors' => static::$errors, 'error_counter' => static::$error_counter, 'count_external_error' => static::$count_external_error)); fn_set_notification('I', __('ebay_end_summary_title'), $smarty->fetch('addons/ebay/views/ebay/components/end_summary.tpl')); }
/** * @return \Ebay\ProductVariation[] */ protected function getProductCombinations() { return $this->product->getCombinations(); }
function fn_update_ebay_template($data, $template_id = 0, $lang_code = CART_LANGUAGE) { if (empty($data['name'])) { return false; } unset($data['template_id']); if (fn_allowed_for('ULTIMATE')) { // check that template owner was not changed by store administrator if (Registry::get('runtime.company_id') || empty($data['company_id'])) { $template_company_id = db_get_field('SELECT company_id FROM ?:ebay_templates WHERE template_id = ?i', $template_id); if (!empty($template_company_id)) { $data['company_id'] = $template_company_id; } else { if (Registry::get('runtime.company_id')) { $template_company_id = $data['company_id'] = Registry::get('runtime.company_id'); } else { $template_company_id = $data['company_id'] = fn_get_default_company_id(); } } } else { $template_company_id = $data['company_id']; } } else { if (Registry::get('runtime.company_id')) { $template_company_id = Registry::get('runtime.company_id'); } else { $template_company_id = $data['company_id']; } } if (fn_allowed_for('ULTIMATE') && Registry::get('runtime.company_id') && !empty($template_company_id) && Registry::get('runtime.company_id') != $template_company_id) { $create = false; } else { $isUpdate = false; if (isset($data['payment_methods']) && is_array($data['payment_methods'])) { $data['payment_methods'] = implode(',', $data['payment_methods']); } if (empty($data['root_sec_category'])) { $data['sec_category'] = ''; } if (!empty($template_id)) { $isUpdate = true; db_query('UPDATE ?:ebay_templates SET ?u WHERE template_id = ?i', $data, $template_id); db_query('UPDATE ?:ebay_template_descriptions SET ?u WHERE template_id = ?i AND lang_code = ?s', $data, $template_id, $lang_code); if (isset($_REQUEST['share_objects']) && isset($_REQUEST['share_objects']['ebay_templates']) && isset($_REQUEST['share_objects']['ebay_templates'][$template_id])) { $_products = db_get_fields("SELECT product_id FROM ?:products WHERE company_id NOT IN (?n) AND ebay_template_id = ?i", $_REQUEST['share_objects']['ebay_templates'][$template_id], $template_id); if (!empty($_products)) { db_query("UPDATE ?:products SET ebay_template_id = 0 WHERE product_id IN (?n)", $_products); } } } else { $data['template_id'] = $template_id = db_query("INSERT INTO ?:ebay_templates ?e", $data); if (isset($data['name']) && empty($data['name'])) { unset($data['name']); } if (!empty($data['name'])) { foreach (fn_get_translation_languages() as $data['lang_code'] => $_v) { db_query("INSERT INTO ?:ebay_template_descriptions ?e", $data); } } } if ($data['use_as_default'] == 'Y') { db_query('UPDATE ?:ebay_templates SET use_as_default = ?s WHERE company_id = ?i AND NOT template_id = ?i', 'N', $template_company_id, $template_id); } if ($template_id && array_key_exists('product_ids', $data)) { if ($isUpdate) { $current_product_ids = \Ebay\Product::getTemplateProductIds($template_id); } else { $current_product_ids = array(); } $data['product_ids'] = (array) $data['product_ids']; $add_product_ids = array_diff($data['product_ids'], $current_product_ids); $delete_product_ids = array_diff($current_product_ids, $data['product_ids']); if (!empty($add_product_ids)) { foreach ($add_product_ids as $product_id) { \Ebay\Product::updateProductTemplateId($product_id, $template_id); } } if (!empty($delete_product_ids)) { foreach ($delete_product_ids as $product_id) { \Ebay\Product::updateProductTemplateId($product_id, 0); } } } } return $template_id; }