Admin Configuration – Customer Prefix Scoped to Website

adminconfigurationcustomer

I wondering if anybody can provide a known reason why customer prefix_options is scope to website level:

<show_in_store>0</show_in_store>

In: app/code/core/Mage/Customer/etc/system.xml

I would like to scope customer prefix values at the store view level and not just website level.

Imagine you have a a website called "Beligum" and in that website you have two store views: be_FR (Beligum-French) and be_NL (Beligum-Dutch). If you wanted to control the customer prefixes at the store view level you can't currently as show_in_store is 0.

Creating a custom module that depends on with a system.xml file to override the value allows me to scope it to the store view level:

<customer>
    <groups>
        <address>
            <fields>
                <prefix_show>
                    <show_in_store>1</show_in_store>
                </prefix_show>
                <prefix_options>
                    <show_in_store>1</show_in_store>
                </prefix_options>
            </fields>
        </address>
    </groups>
</customer>

What I'm interested in is there is any negative side affects that I should look for? Or is this simply not scoped to store view level because Customers in Magento belong to websites?

Thanks

Best Answer

It's not entirely safe:

  1. `Mage::helper('customer')->getNamePrefixOptions() delegates to the customer/address helper.

  2. In Mage::helper('customer/address')->getConfig() you can see that it does not actually use the website model and it's getConfig() method, but uses a per-request cache, which it sets to the value of the current store or given store object.

Where this would go wrong is imports collections. Once it's set it's tied to the website ID and any subsequent invocations of the method for another store in the same website, would get the wrong value:

// Mage_Customer_Helper_Address
/**
 * Return customer address config value by key and store
 *
 * @param string $key
 * @param Mage_Core_Model_Store|int|string $store
 * @return string|null
 */
public function getConfig($key, $store = null)
{
    $websiteId = Mage::app()->getStore($store)->getWebsiteId();

    if (!isset($this->_config[$websiteId])) {
        $this->_config[$websiteId] = Mage::getStoreConfig('customer/address', $store);
    }
    return isset($this->_config[$websiteId][$key]) ? (string)$this->_config[$websiteId][$key] : null;
}

Aside: getNamePrefixOptions() is used in the Customer/Name widget, but this would go ok in the normal usage, as the store wouldn't switch within a request.

Edit: Not sure why I wrote imports late last night, but it's collections obviously. Think the newsletter, wishlist and other reminder emails and since 1.9.1 also the transactional emails as they're also being grouped now.

Related Topic