OpenMage / magento-lts

Official OpenMage LTS codebase | Migrate easily from Magento Community Edition in minutes! Download the source code for free or contribute to OpenMage LTS | Security vulnerability patches, bug fixes, performance improvements and more.
https://www.openmage.org
Open Software License 3.0
866 stars 436 forks source link

New feature: Highlight popular countries in country select #4089

Open ma4nn opened 2 months ago

ma4nn commented 2 months ago

Description (*)

This PR backports a feature from Magento 2 (in a nicer way with option groups) that allows to configure countries that will be shown on top of the country list ("popular countries").

Also the code duplication for Mage_Checkout_Block_Onepage_Abstract::getCountryHtmlSelect() and Mage_Directory_Block_Data::getCountryHtmlSelect() is removed.

In addition a new event directory_get_top_countries is added, that allows to customize the logic (e.g. to determine top countries automatically from quotes/orders).

Bildschirmfoto 2024-07-07 um 11 15 54

Related Pull Requests

Fixed Issues (if relevant)

Manual testing scenarios (*)

Repeat the following tests 1.-5. for country dropdown in

  1. Disable config cache
  2. Without any configuration the country dropdown looks the same as before
  3. Configure one top country in System > Configuration > General > Countries Options > Top Countries and verify the country dropdown
  4. Configure multiple top countries in System > Configuration > General > Countries Options > Top Countries and verify the country dropdown
  5. Enable config cache, assure options are cached by reloading page multiple times and repeat steps 2-4
  6. Verify product attribute country_of_manufacture uses non-sorted country list in backend
  7. Verify product attribute country_of_manufacture can be displayed correctly on product detail page
  8. In checkout select "Ship to different address", then in shipping form select "Use Billing Address" and change country value -> "Use Billing Address" should be unchecked then

Questions or comments

Contribution checklist (*)

SuSiSonnenschein111 commented 2 months ago

Please re-check ... cache-key DIRECTORY_COUNTRY_SELECT_STORE_ is used at several places ... (not tested nothing, just an idea)

ma4nn commented 2 months ago

Please re-check ... cache-key DIRECTORY_COUNTRY_SELECT_STORE_ is used at several places ... (not tested nothing, just an idea)

@SuSiSonnenschein111 thanks for your feedback (although it could have been a little bit more detailed). By "several places" you mean Mage_Catalog_Model_Product_Attribute_Source_Countryofmanufacture?

But I agree, the result before sorting should be cached, I've pushed the change and extended the testing scenarios.

Moreover probably Mage_Catalog_Model_Product_Attribute_Source_Countryofmanufacture::getAllOptions() and Mage_Directory_Block_Data::getCountryHtmlSelect() should also be refactored further to remove the code duplication..

sreichel commented 1 week ago

Looks good so far ..., but for some reason i have a wrong translation for country selction dropdown ...

country

It is not related to this PR ... i see the same on main-branch.

The only occourence of "Allemagne" is in vendor/shardj/zf1-future/library/Zend/Locale/Data/fr.xml.