Magento:每个商店加载属性
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?
我有一个自定义模块,可在用户结账时将数据导出到我们的履行系统。 在导出之前,我需要通过验证服务运行该地址。 由于我们需要为此服务付费,因此我需要为每个商店配置服务的用户名和密码。 我添加了我需要的属性,但是我无法弄清楚如何在每个商店加载它们。 如何根据商店告知我的资源模型加载? p> div>
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.