/** * 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; }
/** * Uninstall ebay addon * @internal */ function fn_ebay_uninstall() { \Ebay\objects\Site::clearLastSynchronizationTime(); \Ebay\objects\Category::clearLastSynchronizationTime(); \Ebay\objects\Category::clearCategoryVersions(); \Ebay\objects\Shipping::clearLastSynchronizationTime(); }