Skip to content

Commit

Permalink
Merge pull request #1075 from Hlavtox/pr-37592
Browse files Browse the repository at this point in the history
Set new option of lang prefix dynamically
  • Loading branch information
Hlavtox authored Dec 17, 2024
2 parents 00f5f4f + f191da2 commit b5fa1ac
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 3 deletions.
45 changes: 45 additions & 0 deletions upgrade/php/ps_900_set_url_lang_prefix.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php
/**
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/OSL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to https://devdocs.prestashop.com/ for more information.
*
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* @author PrestaShop SA and Contributors <[email protected]>
*/

use PrestaShop\Module\AutoUpgrade\DbWrapper;

/**
* @return void
*
* @throws \PrestaShop\Module\AutoUpgrade\Exceptions\UpdateDatabaseException
*/
function ps_900_set_url_lang_prefix()
{
$numberOfActiveLanguages = (int) DbWrapper::getValue(
'SELECT COUNT(*) AS lang_count FROM `' . _DB_PREFIX_ . 'lang` WHERE `active` = 1'
);

if ($numberOfActiveLanguages > 1) {
Configuration::updateValue('PS_DEFAULT_LANGUAGE_URL_PREFIX', 1);
} else {
Configuration::updateValue('PS_DEFAULT_LANGUAGE_URL_PREFIX', 0);
}
}
7 changes: 4 additions & 3 deletions upgrade/sql/9.0.0.sql
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
SET SESSION sql_mode='';
SET NAMES 'utf8mb4';

/* Enable controlling of default language URL prefix - https://github.com/PrestaShop/PrestaShop/pull/37236 */
/* Add a file separator input to the sql manager settings - https://github.com/PrestaShop/PrestaShop/pull/35843 */
/* Allow configuring maximum word difference - https://github.com/PrestaShop/PrestaShop/pull/37261 */
INSERT INTO `PREFIX_configuration` (`name`, `value`, `date_add`, `date_upd`) VALUES
('PS_DEBUG_COOKIE_NAME', '', NOW(), NOW()),
('PS_DEBUG_COOKIE_VALUE', '', NOW(), NOW()),
('PS_SEPARATOR_FILE_MANAGER_SQL', ';', NOW(), NOW()),
('PS_PRODUCT_BREADCRUMB_CATEGORY', 'default', NOW(), NOW()),
('PS_SEARCH_FUZZY_MAX_DIFFERENCE', 5, NOW(), NOW()),
('PS_DEFAULT_LANGUAGE_URL_PREFIX', 1, NOW(), NOW())
('PS_SEARCH_FUZZY_MAX_DIFFERENCE', 5, NOW(), NOW())
;

/* Enable controlling of default language URL prefix - https://github.com/PrestaShop/PrestaShop/pull/37236 */
/* PHP:ps_900_set_url_lang_prefix(); */;

/* Remove meta keywords - https://github.com/PrestaShop/PrestaShop/pull/36873 */
/* PHP:drop_column_if_exists('category_lang', 'meta_keywords'); */;
/* PHP:drop_column_if_exists('cms_lang', 'meta_keywords'); */;
Expand Down

0 comments on commit b5fa1ac

Please sign in to comment.