简体   繁体   中英

Magento: Loading attributes per store

I have a custom module that exports data to our fulfillment system when the user checks out. Before export I need to run the address through a verification service. Since we are charged for this service, I need to configure the user name and password for the service per store. I have added the attributes I need, however I cannot figure out how to load them per store. How can I tell my resource model to load based off the store?

How have you added them? It strikes me that they'd be perfect candidates for config values, and Magento wraps the whole per-store-setting thing there really well - take a look in a system.xml file for one of the built-in modules (or a downloaded one...they tend to be simpler) and how it builds the fields up and specifies at what 'scope' (global, store, store-view) settings can be applied.

Then you can access the values from your code with Mage::getStoreConfigValue('your/config/key') and it will give you the correct value for the scope you're in, or the default if you haven't set one for a particular store.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM