magento-lts
magento-lts copied to clipboard
Use transliterator_transliterate to generate url_key
Description
When a product or a category url key use special characters, they are substituted with strstr. With this PR, transliteration is used (with PHP INTL).
Tested with the following locales: fr-FR, es-ES, de-DE, it-IT, pt-PT, nl-NL, pl-PL, cs-CZ, sk-SK, ru-RU, uk-UA. OpenMage 20.x / PHP 7.4.6 and 8.0.x and 8.2.x
Manual testing scenarios
- Set default locale to French.
- Set first store locale to Russian.
- Set second store locale to French.
- Create a product and category with the following name: Массажный Аппарат для Похудения A
- Set the product and category name on first store to: Массажный Аппарат для Похудения B
- Set the product and category name on second store to: Массажный Аппарат для Похудения C
Run:
DELETE FROM catalog_category_entity_varchar WHERE attribute_id IN (
SELECT attribute_id FROM eav_attribute WHERE attribute_code LIKE 'url_key');
DELETE FROM catalog_product_entity_varchar WHERE attribute_id IN (
SELECT attribute_id FROM eav_attribute WHERE attribute_code LIKE 'url_key');
Run:
rm -rf var/cache/ ; php shell/indexer.php reindexall ; rm -rf var/cache/
Check url keys generated:
- all store views:
massazhnyj-apparat-dlja-pohudenija-b - first store:
massazhnyj-apparat-dlja-pohudenija-b - second store:
massazhnyj-apparat-dlja-pohudenija-b
That's wrong, and not good. So apply the PR, clear existing url keys (first run), reindex and clear cache (second run).
Check url keys generated:
- all store views:
massaznyj-apparat-dla-pohudenia-a - first store:
massazhnyy-apparat-dlya-pokhudeniya-b - second store:
massaznyj-apparat-dla-pohudenia-c
That's better.
Extra: for CMS / Pages, when an user create a new page without url key, an url key is generated.
Contribution checklist
- [x] Pull request has a meaningful description of its purpose
- [x] All commits are accompanied by meaningful commit messages
- [x] All automated tests passed successfully (all builds are green)
- [x] Add yourself to contributors list
If this is part of "intl" we've to require ext-intl in composer.json, which would also help https://github.com/OpenMage/magento-lts/pull/2411 cause we wouldn't need Net_IRDA anymore
Is this code (#345) still required?
You are right, the function removeAccents must be updated! I discovered it now.
It seems that openmage doesn't use it?
https://github.com/OpenMage/magento-lts/blob/f48e168f15453c9771bf91f93e06c70432e2b3b0/app/code/core/Mage/Core/Helper/Data.php#L332-L389
Perhaps simply:
public function removeAccents($string)
{
$locale = Mage::getStoreConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_LOCALE, $this->getStoreId());
return Mage::helper('catalog/product_url')->format($string, $locale);
}
@luigifab i'll check conflicts after weekend.
ping @sreichel :) ?
Sorry, no. I'm not active here anymore.
as per https://github.com/OpenMage/rfcs/pull/7 I think this should be targeting 20.0, what do you think?
:'( how can I change the base branch??
:'( how can I change the base branch??
From Desktop click Edit on the top right corner then select the branch from the dropdown.
Good! I forgot where it was.
@luigifab since today we've to rebase to the main branch ;-)
I like this PR but it modified the signature of a lot of public methods, so it has to be moved to the next branch and considered a breaking change
@luigifab do you use this PR in production?
Yes!