示例#1
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;
 }
示例#2
0
    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'];
    $category_id = (int) $_REQUEST['category_id'];
    $template_data = $features = array();
    if (\Ebay\objects\CategoryFeature::isNeedSynchronization($site_id, $category_id)) {
        \Ebay\objects\CategoryFeature::synchronization($site_id, $category_id);
    }
    $current_category = \Ebay\objects\Category::getCategory($site_id, $category_id);
    if (!empty($_REQUEST['template_id'])) {
        $template_data = fn_get_ebay_template($_REQUEST['template_id']);
    }
    Tygh::$app['view']->assign('template_data', $template_data);
    Tygh::$app['view']->assign('current_category', $current_category);
    Tygh::$app['view']->assign('data_id', $_REQUEST['data_id']);
    if (defined('AJAX_REQUEST')) {
        Tygh::$app['view']->display('addons/ebay/views/ebay/components/category_features.tpl');
        exit;
    } else {
        array(CONTROLLER_STATUS_REDIRECT, 'ebay.manage');
    }
} elseif ($mode == 'get_subcategories') {
示例#3
0
/**
 * Return array objects need synchronization
 * @param int $site_id
 * @param int|null $category_id
 * @return array
 */
function fn_ebay_get_objects_needed_synchronization($site_id, $category_id = null)
{
    $result = array('Site' => \Ebay\objects\Site::isNeedSynchronization(), 'Category' => \Ebay\objects\Category::isNeedSynchronization($site_id), 'Shipping' => \Ebay\objects\Shipping::isNeedSynchronization($site_id));
    if ($category_id !== null) {
        $result['CategoryFeature'] = \Ebay\objects\CategoryFeature::isNeedSynchronization($site_id, $category_id);
    }
    return array_keys(array_filter($result));
}