EXPLAIN FORMAT=JSON
automatically if you use MySQL 5.7update_handlers
parameter could be.Bootstrap::sendHeaders()
method doesn’t send cache-restricting headers Expires
, Last-Modified
, Cache-Control
, and Pragma
. Sending those headers is delegated to the session_start()
function call. It will send correct headers based on the session.cache_limiter
PHP configuration parameter value.\Tygh\Providers
namespace and are registered in the init.php file.Tygh::$app['db']
.
\Tygh\Database
now doesn’t contain any logic and proxies all method calls to the newTygh::$app['db']
component.All database functions such as
db_query
still work like earlier, but they now use the new component internally.All of your code will work as earlier, but the
\Tygh\Database
class is now deprecated and will be removed in the next major release (5.x)You may now use several DB connections transparently by adding one more DB connection component to the service locator:
// Create a new instance of connection Tygh::$app['replication_db'] = new \Tygh\Database\Connection(new \Tygh\Backend\Database\Pdo()); // Establish connection to the DB Tygh::$app['replication_db']->connect('user', 'password', 'localhost', 'db_name', array('table_prefix' => 'cscart_')); // Run queries! $user = Tygh::$app['replication_db']->getRow('SELECT * FROM ?:users WHERE user_id = ?i', 1);
- You may want to take a look at the app/Tygh/Providers/DatabaseProvider.php and app/Tygh/Database/Connection.php files for deeper understanding of internal mechanisms.
php \Tygh::$app['view']->display('backend:views/debugger/debugger.tpl');
\Tygh\Http
class:
- The
encoding
extra parameter was added for cURL requests; it stands forCURLOPT_ENCODING
parameter- Multi-requests no more trigger 100% CPU usage
Tygh::$app['session']
component.
Code for writing into a session:
php Tygh::$app['session']['cart'] = array(); Tygh::$app['session']['cart']['products'][] = array();Code for reading from the session:
php $cart = Tygh::$app['session']['cart']; // or by link $cart = & Tygh::$app['session']['cart'];It works the same way as working with
$_SESSION
directly. However,Tygh::$app['session']
belongs to the\Tygh\Web\Session
class. This class replaces the old\Tygh\Session
and allows to address to session data with the array syntax.The old
Tygh\Session
class is deprecated. However, it still works, because it proxies all method calls to theTygh::$app['session']
. We have replaced usage of\Tygh\Session
withTygh::$app['session']
in the core and standard add-ons.Note
The code that uses
$_SESSION
directly may not work as intended with full-page caching turned on.We also implemented service providers. A service provider is a class, an instance of which registers any components and values in the Application container (otherwise known as Service Locator).
We added the
\Tygh\Providers
namespace and the first provider\Tygh\Providers\SessionProvider
, that registers the values ofsession
,session.storage
andsession.storage.class
in the container.
\Tygh\Tools\Archivers
namespace. All existing functions now internally use the new code with backward compatibility preserved. Also, the Archive_Tar
class was re-included into CS-Cart and is used as a fallback when the PharData
class fails to perform.Perform any actions before actually rendering a block:
fn_set_hook('render_block_pre', $block, $block_schema, $params, $block_content);
Perform any actions after actually rendering a block:
fn_set_hook('render_block_post', $block, $block_schema, $block_content, $load_block_from_cache, $display_this_block, $params);
This hook is executed before saving cache data to persistent storage and clearing expired cache:
fn_set_hook('registry_save_pre', self::$_changed_tables, self::$_cached_keys);
This hook is executed before updating a setting value by setting object ID:
fn_set_hook('settings_update_value_by_id_pre', $this, $object_id, $value, $company_id, $execute_functions, $data, $old_data, $table);
This hook is executed after updating a setting value by setting object ID:
fn_set_hook('settings_update_value_by_id_post', $this, $object_id, $value, $company_id, $execute_functions, $data, $old_data, $table);
Modify product chain update parameters:
fn_set_hook('buy_together_update_chain_pre', $item_id, $product_id, $item_data, $auth, $lang_code);
Modify product chain update results:
fn_set_hook('buy_together_update_chain_post', $item_id, $product_id, $item_data, $auth, $lang_code);
Modify product chain get parameters:
fn_set_hook('buy_together_get_chains_pre', $parms, $auth, $lang_code);
Change select condition (fields, conditions, joins) before selecting payment method data:
fn_set_hook('buy_together_get_chains', $params, $auth, $lang_code, $fields, $conditions, $joins);
Get a function result along with parameters and query information:
fn_set_hook('buy_together_get_chains_post', $params, $auth, $lang_code, $chains, $fields, $conditions, $joins);
Modify the parameters of the query that fetches discussion posts:
fn_set_hook('get_discussion_posts_pre', $params, $items_per_page);
Modify the query that gets discuission posts:
fn_set_hook('get_discussion_posts', $params, $items_per_page, $fields, $join, $condition, $order_by, $limit);
Modify discussion posts and request parameters:
fn_set_hook('get_discussion_posts_post', $params, $items_per_page, $posts);
Modifiy disscussed object properties:
fn_set_hook('delete_discussion_pre', $object_id, $object_type);
Modify deletion results:
fn_set_hook('delete_discussion_post', $object_id, $object_type, $is_deleted);
Modify deleting discussion post identifier:
fn_set_hook('discussion_delete_post_pre', $post_id);
Modify deleted discussion post identifier:
fn_set_hook('discussion_delete_post_post', $post_id);
Modify title strings for different discussion types:
fn_set_hook('get_discussion_titles', $discussion_object_titles);
The post hook for checking detailed image size ratio:
fn_set_hook('image_zoom_check_image_post', $file_path, $image_data, $images);
This hook is executed before changing add-on status (i.e. before enabling or disabling an add-on):
fn_set_hook('update_addon_status_pre', $addon, $status, $show_notification, $on_install, $allow_unmanaged, $old_status, $scheme);
This hook is executed after changing add-on status (i.e. after enabling or disabling an add-on):
fn_set_hook('update_addon_status_post', $addon, $status, $show_notification, $on_install, $allow_unmanaged, $old_status, $scheme);
Filter product data:
fn_set_hook('filter_product_data', $request, $product_data);
Modify top menu forming parameters:
fn_set_hook('top_menu_form_pre', $top_menu, $level, $active);
Modify top menu items:
fn_set_hook('top_menu_form_post', $top_menu, $level, $active);
This hook is executed before saving enabled customization modes to the database:
fn_set_hook('update_customization_mode', $modes, $enabled_modes, $available_modes);
Prepare statuses for particular object type:
fn_set_hook('get_predefined_statuses', $type, $statuses, $status);
Perform actions before changing company status:
fn_set_hook('change_company_status_pre', $company_id, $status_to, $reason, $status_from, $skip_query, $notify);
Perform actions between changing company status and sending an e-mail:
fn_set_hook('change_company_status_before_mail', $company_id, $status_to, $reason, $status_from, $skip_query, $notify, $company_data, $user_data, $result);
Perform actions before creating a company admin:
fn_set_hook('create_company_admin_pre', $company_data, $fields, $notify);
Perform actions before creating a company admin directly:
fn_set_hook('create_company_admin', $company_data, $fields, $notify, $user);
Perform actions after creating a company admin:
fn_set_hook('create_company_admin_post', $company_data, $fields, $notify, $user);
Perform actions before an HTTP response is sent to the client. This is the last place where you can modify the HTTP headers list:
fn_set_hook('dispatch_before_send_response', $status, $area, $controller, $mode, $action);
Perform actions after saving a vendor payout:
fn_set_hook('mve_place_order_post', $order_id, $action, $order_status, $cart, $auth, $order_info, $company_data, $data, $payout_id);
fn_set_hook('top_menu_form', $v, $type, $id, $use_name);
is now deprecated
// old:
fn_set_hook('render_block_content_after', $block_schema, $block, $block_content);
// new:
fn_set_hook('render_block_content_after', $block_schema, $block, $block_content, $params, $load_block_from_cache);
// old:
fn_set_hook('get_categories_after_sql', $categories, $params);
// new:
fn_set_hook('get_categories_after_sql', $categories, $params, $join, $condition, $fields, $group_by, $sortings, $sorting, $limit, $lang_code);
// old:
fn_set_hook('get_category_data', $category_id, $field_list, $join, $lang_code);
// new:
fn_set_hook('get_category_data', $category_id, $field_list, $join, $lang_code, $conditions);
// old:
fn_set_hook('clone_product_option_post', $from_product_id, $to_product_id, $from_global_option_id, $v);
// new:
fn_set_hook('clone_product_option_post', $from_product_id, $to_product_id, $from_global_option_id, $option_data, $change_options, $change_variants);
// old:
fn_set_hook('delete_status_pre', $status, $type, $can_delete);
// new:
fn_set_hook('delete_status_pre', $status, $type, $can_delete, $is_default, $status_id);
// old:
fn_set_hook('delete_status_post', $status, $type, $can_delete);
// new:
fn_set_hook('delete_status_post', $status, $type, $can_delete, $is_default, $status_id);
// old:
fn_set_hook('update_image', $image_data, $image_id, $image_type, $images_path, $_data);
// new:
fn_set_hook('update_image', $image_data, $image_id, $image_type, $images_path, $_data, $mime_type);
// old:
fn_set_hook('mve_place_order', $order_info, $company_data, $action, $__order_status, $cart, $_data);
// new:
fn_set_hook('mve_place_order', $order_info, $company_data, $action, $order_status, $cart, $data, $payout_id, $auth);
Create logos of missing logo types for a given layout and style:
\Tygh\Themes\Styles::createMissedLogoTypesForLayout($layout_id, $style_id)
Set theme manifest contents:
\Tygh\Themes\Themes::setManifest($manifest_data)
Get theme setting overrides:
\Tygh\Themes\Themes::getSettingsOverrides($lang_code = CART_LANGUAGE)
Override settings values from theme manifest file:
\Tygh\Themes\Themes::overrideSettings($settings = null, $company_id = null)
Create a clone of the theme:
\Tygh\Themes\Themes::cloneAs($clone_name, $clone_data = array(), $company_id = 0)
Return all variables stored in the registry:
\Tygh\Registry::getAll()
Return all cache keys:
\Tygh\Registry::getAll()
\Tygh\Tools\Url::setHost()
\Tygh\Tools\Url::setQueryString()
\Tygh\Tools\Url::getQueryString()
\Tygh\Tools\Url::setPath()
\Tygh\Tools\Url::getPath()
Check if a given URL is a subpart of the current URL by matching their paths:
\Tygh\Tools\Url::containsAsSubpath(self $url)
Check detailed image size ratio:
fn_image_zoom_check_image(&$image_data, &$images)
Generate SEO Canonical, Prev, Next links:
fn_seo_get_canonical_links($base_url, $search)
fn_exim_quote(&$value, $quote = "'")
Add the current company_id
as altkey if an object doesn’t have store defined. Needed to determine primary object correctly:
fn_exim_apply_company($pattern, &$alt_keys, &$object, &$skip_get_primary_object_id)
Filtration conditions and bonus values:
fn_promotions_filter_data($data)
Filtration condition values:
fn_promotions_filter_conditions($conditions)
Filtration bonus values:
fn_promotions_filter_bonuses($bonuses)
Return the path to addon layouts file in specified theme:
fn_get_addon_layouts_path($addon_name, $theme_name = '[theme]')
Store the shipping rates when managing an order:
fn_store_shipping_rates($order_id = 0, &$cart, $customer_auth)
Filter product data before saving:
fn_filter_product_data(&$request, &$product_data)
Check permission for changing the store mode:
fn_check_change_store_mode_permission()
Get the list of predefined statuses for a particular object type:
fn_get_predefined_statuses($type, $status = '')
Delete a status, its description, and data by the status identifier:
fn_delete_status_by_id($status_id)
Return a status identifier by the status code and type:
fn_get_status_id($status, $type, $is_default = null)
Return the statuses of a specified type:
fn_get_statuses_by_type($type)
Change a company status. Allowed statuses are A
(active) and D
(disabled):
fn_change_company_status($company_id, $status_to, $reason = '', &$status_from = '', $skip_query = false, $notify = true)
Create a company admin:
fn_create_company_admin($company_data, $fields = '', $notify = false)
Check if the current user has access to the specified permission:
fn_check_current_user_access($permission)
\Tygh\Themes\Styles::getCustomFonts()
became public
\Tygh\Tools\Url::__construct()
can now be called without any arguments
fn_exim_set_quotes()
is now deprecated in favour of fn_exim_quote()
fn_companies_change_status()
is now deprecated in favour of fn_change_company_status()
// old:
public static function sanitizeData(array $data, array $rules, array $disabled_actions = array())
// new:
public static function sanitizeData(array $data, array $rules, array $disabled_actions = array(), &$changed = false)
// old:
function fn_install_addon($addon, $show_notification = true, $install_demo = false)
// new:
function fn_install_addon($addon, $show_notification = true, $install_demo = false, $allow_unmanaged = false)
// old:
function fn_update_addon_status($addon, $status, $show_notification = true, $on_install = false)
// new:
function fn_update_addon_status($addon, $status, $show_notification = true, $on_install = false, $allow_unmanaged = false)
// old:
function fn_get_subcategories($category_id = '0', $lang_code = CART_LANGUAGE)
// backward compatibility preserved
// new:
function fn_get_subcategories($category_id = '0', $params = array(), $lang_code = CART_LANGUAGE)
// old:
function fn_delete_status($status, $type)
// new:
function fn_delete_status($status, $type, $is_default = false)
// old:
function fn_create_theme_logos_by_layout_id($theme_name, $layout_id = 0, $company_id = null, $for_company = false, $style_id = '')
// new:
function fn_create_theme_logos_by_layout_id($theme_name, $layout_id = 0, $company_id = null, $for_company = false, $style_id = '', $whitelist_of_logo_types = null)
// old:
function fn_get_logos($company_id = null, $layout_id = 0, $style_id = '')
// new:
function fn_get_logos($company_id = null, $layout_id = null, $style_id = null)
// old:
function fn_generate_thumbnail($image_path, $width, $height = 0, $lazy = false)
// new:
function fn_generate_thumbnail($image_path, $width, $height = 0, $lazy = false, $return_rel_path = false)
// old:
function fn_login_user($user_id = '')
// new:
function fn_login_user($user_id = 0, $regenerate_session_id = false)
Questions & Feedback
Have any questions that weren't answered here? Need help with solving a problem in your online store? Want to report a bug in our software? Find out how to contact us.