Allowed Countries Keeps Resetting to All in Magento 1.9

cacheindexingmagento-1.9

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

Best Answer

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.

Related Topic