示例#1
0
        $template_data['category'] = (int) $_REQUEST['category_id'];
    }
    if (isset($_REQUEST['shipping_type'])) {
        $template_data['shipping_type'] = $_REQUEST['shipping_type'];
    }
    // [Page sections]
    Registry::set('navigation.tabs', array('detailed' => array('title' => __('general'), 'js' => true), 'shippings' => array('title' => __('shippings'), 'js' => true), 'payments' => array('title' => __('payments'), 'js' => true), 'returnPolicy' => array('title' => __('return_policy'), 'js' => true)));
    if (empty($template_data['shipping_type'])) {
        $template_data['shipping_type'] = 'C';
    }
    if (!isset($template_data['category'])) {
        $template_data['category'] = null;
    }
    /** @var Smarty $view */
    $view = Tygh::$app['view'];
    $objects = fn_ebay_get_objects_needed_synchronization($template_data['site_id'], $template_data['category']);
    $view->assign('need_synchronisation', !empty($objects));
    $view->assign('ebay_domestic_shipping_services', fn_get_ebay_shippings($template_data['site_id'], $template_data['shipping_type'] == 'C' ? 'Calculated' : 'Flat', false));
    $view->assign('ebay_international_shipping_services', fn_get_ebay_shippings($template_data['site_id'], $template_data['shipping_type'] == 'C' ? 'Calculated' : 'Flat', true));
    if (!empty($template_data['root_category'])) {
        $view->assign('ebay_child_categories', fn_get_ebay_categories($template_data['site_id'], $template_data['root_category'], true));
    }
    if (!empty($template_data['root_sec_category'])) {
        $view->assign('ebay_sec_child_categories', fn_get_ebay_categories($template_data['site_id'], $template_data['root_sec_category'], true));
    }
    if (!empty($template_data['category'])) {
        $view->assign('current_category', \Ebay\objects\Category::getCategory($template_data['site_id'], $template_data['category']));
    }
    $view->assign('template_data', $template_data)->assign('ebay_sites', fn_get_ebay_sites())->assign('ebay_root_categories', fn_get_ebay_categories($template_data['site_id'], 0));
} elseif ($mode == 'get_category_features') {
    $site_id = (int) $_REQUEST['site_id'];
示例#2
0
 /**
  * Sync ebay objects
  * @param int $site_id
  * @param int $category_id
  * @return bool
  */
 public static function synchronizationObjects($site_id, $category_id)
 {
     @set_time_limit(600);
     $start_time = fn_get_storage_data('ebay_synchronization_start_time');
     if (!empty($start_time) && $start_time > strtotime('-10 minutes')) {
         $time = time();
         $current_step = fn_get_storage_data('ebay_synchronization_step');
         $count_steps = fn_get_storage_data('ebay_synchronization_step_count');
         fn_set_progress('title', __('ebay_synchronization_title'));
         fn_set_progress('parts', $count_steps);
         for ($i = 1; $i < $current_step; $i++) {
             fn_set_progress('echo', '.');
         }
         fn_set_progress('echo', fn_get_storage_data('ebay_synchronization_step_title'), false);
         while (true) {
             //TODO move logic to same function fn_get_storage_data
             Registry::del('storage_data.ebay_synchronization_step');
             Registry::del('storage_data.ebay_synchronization_step_title');
             $step = fn_get_storage_data('ebay_synchronization_step');
             if (empty($step)) {
                 return true;
             }
             if ($step != $current_step) {
                 fn_set_progress('echo', '.');
                 fn_set_progress('echo', fn_get_storage_data('ebay_synchronization_step_title'), false);
                 $current_step = $step;
             }
             if ($time < strtotime('-10 minutes')) {
                 return true;
             }
             sleep(1);
         }
         return true;
     }
     $objects = fn_ebay_get_objects_needed_synchronization($site_id, $category_id);
     if (!empty($objects)) {
         $current_step = 1;
         register_shutdown_function(function () {
             fn_set_storage_data('ebay_synchronization_start_time', null);
             fn_set_storage_data('ebay_synchronization_step_title', null);
             fn_set_storage_data('ebay_synchronization_step', null);
             fn_set_storage_data('ebay_synchronization_step_count', null);
         });
         fn_set_storage_data('ebay_synchronization_start_time', time());
         fn_set_storage_data('ebay_synchronization_step_count', count($objects));
         fn_set_storage_data('ebay_synchronization_step', $current_step);
         fn_set_progress('title', __('ebay_synchronization_title'));
         fn_set_progress('parts', count($objects));
         if (in_array('Site', $objects)) {
             fn_set_progress('echo', __('ebay_synchronization_regions'), false);
             fn_set_storage_data('ebay_synchronization_step_title', __('ebay_synchronization_regions'));
             Site::synchronization();
             fn_set_storage_data('ebay_synchronization_step', ++$current_step);
             fn_set_progress('echo', '.');
         }
         if (in_array('Category', $objects)) {
             fn_set_progress('echo', __('ebay_synchronization_categories'), false);
             fn_set_storage_data('ebay_synchronization_step_title', __('ebay_synchronization_categories'));
             Category::synchronization($site_id);
             fn_set_storage_data('ebay_synchronization_step', ++$current_step);
             fn_set_progress('echo', '.');
         }
         if (in_array('Shipping', $objects)) {
             fn_set_progress('echo', __('ebay_synchronization_shipping_services'), false);
             fn_set_storage_data('ebay_synchronization_step_title', __('ebay_synchronization_shipping_services'));
             Shipping::synchronization($site_id);
             fn_set_storage_data('ebay_synchronization_step', ++$current_step);
             fn_set_progress('echo', '.');
         }
         if (in_array('CategoryFeature', $objects)) {
             fn_set_progress('echo', __('ebay_synchronization_category_features'), false);
             fn_set_storage_data('ebay_synchronization_step_title', __('ebay_synchronization_category_features'));
             CategoryFeature::synchronization($site_id, $category_id);
             fn_set_storage_data('ebay_synchronization_step', ++$current_step);
             fn_set_progress('echo', '.');
         }
     }
     return true;
 }