2

I have an issue in Magento 1.9.0.1 where my allowed countries keep showing every country in the frontend.

I did a search and came across this: Allow countries keeps resetting and allowing all on frontend?

I tried the XML updates, but that didn't do anything.

I disabled the cache and it went back to normal. I discovered that if I have cache enabled and then reindex, the problem will show up and persist until I flush the cache.

Any idea what the issue could be?

Thanks

5

This should actually be fixed since 1.7.0.0 according to the Release Notes, but it seems it is not.

I ran into this issue once with product pages using the country of manufacture attribute.

The country dropdown is added in app/design/frontend/base/default/template/checkout/onepage/billing.phtml and shipping.phtml with the <?php echo $this->getCountryHtmlSelect('billing') ?> and <?php echo $this->getCountryHtmlSelect('shipping') ?> method.

These methods refer to the getCountryHtmlSelect($type) method of Mage_Checkout_Block_Onepage_Abstract where the country options are gathered in getCountryOptions(). There you can see, that the cache-id $cacheId = 'DIRECTORY_COUNTRY_SELECT_STORE_' . Mage::app()->getStore()->getCode(); is set.

The country of manufacture attribute is loaded via Mage_Catalog_Model_Product_Attribute_Source_Countryofmanufacture where in the getAllOptions() method the same cache-id $cacheKey = 'DIRECTORY_COUNTRY_SELECT_STORE_' . Mage::app()->getStore()->getCode(); is used.

This means: If you load a product page first where the country of manufacture is used, all the country options are available as there is no restriction. Same applies if you refresh the cache.

| improve this answer | |
  • 1
    Thanks. I fixed this by following the advice here: youtube.com/watch?v=HSBNTYdv07o Change the $cacheKey variable prefix in Mage_Catalog_Model_Product_Attribute_Source_Countryofmanufacture from "DIRECTORY_COUNTRY_SELECT_STORE_" to "COUNTRYOFMANUFACTURE_SELECT_STORE_" and clear the cache. – Dylan Nov 15 '14 at 0:52
  • 1
    Great, but please do not modify core files > put this in a class rewrite! Please add your solution as answer then and accept it yourself, to mark this question als closed. This platform is still in beta and this helps to raise the answer rate to 80%. – Anna Völkl Nov 17 '14 at 8:51
  • Thank you! This is still a valid issue and swapping the cache key is a fix in 1.9.2 -- To verify your code update works. Enable and refresh the configuration cache, load a product page first, then visit your checkout page and view the country select and vise versa. – asherrard Feb 8 '16 at 17:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.