Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use transliterator_transliterate to generate "url_key" #4315

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

sreichel
Copy link
Contributor

@sreichel sreichel commented Oct 27, 2024

Description (*)

@luigifab had a great idea to use intl-extension for generating url key with translating all special chars. For me the PR did not work, so tried myself.

This is a non-BC-breaking try of it. It does not change method-signaturer and should be BC-safe. (I did not add all features of #1631. That could be done in another PR.)

To not reinvent the wheel for locale-mapping if have added symfony/string that exactly does what we need.

See: https://symfony.com/doc/current/string.html#slugger

Related Pull Requests

  1. See Used transliterator_transliterate to generate url_key #1631

Manual testing scenarios (*)

  • have multiple store with different languages assigned (eg sample data)
  • edit product title to have some locale specific character/words
    • de_DE: umlauts (äöü)
    • use trademark/copyright/etc.
  • generate new url-key (e.g. changing name) ...

Test product/category before and after ...

$urlKey = 'a & B, x%, ä, ö, ü';
$model = new Mage_Catalog_Model_Product_Url();
if (method_exists($model, 'setLocale')) {
    # $locale = Mage::getStoreConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_LOCALE, <store_id>);
    $model->setLocale('de_DE');
}
var_dump($model->formatUrlKey($urlKey));

Before url-key

'a-b-x-a-o-u'

After url-key

en_US
a-and-b-x-percent-a-o-u
de_DE
a-und-b-x-prozent-ae-oe-ue

Questions or comments

Locale config in xml should be changed to not have language-specif config in core. Any ideas?

Magento already had an unsused config for it ... Mage_Catalog_Helper_Product_Url::__construct looks for Mage::getConfig()->getNode('default/url/convert'); XML.

@github-actions github-actions bot added Component: Core Relates to Mage_Core Component: Catalog Relates to Mage_Catalog Component: ImportExport Relates to Mage_ImportExport composer Relates to composer.json labels Oct 27, 2024
@sreichel sreichel marked this pull request as draft October 27, 2024 16:12
@sreichel sreichel marked this pull request as ready for review October 27, 2024 17:00
@sreichel sreichel changed the title Used transliterator_transliterate to generate "url_key" Use transliterator_transliterate to generate "url_key" Oct 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Catalog Relates to Mage_Catalog Component: Core Relates to Mage_Core Component: ImportExport Relates to Mage_ImportExport composer Relates to composer.json phpstan
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant