获取magento商店列表 [英] Getting a list of magento stores

查看:53
本文介绍了获取magento商店列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何获取Magento网站下的商店组列表,然后从该商店组中获取商店列表?

How can I get a list of store groups under a website in Magento and then a list of stores from that store group?

推荐答案

尝试使用此方法直接获取对象

Try this to get the objects directly

Mage::app()->getWebsites(); < in file > app/code/core/Mage/Core/Model/App.php:920 
Mage::app()->getStores(); < in file > app/code/core/Mage/Core/Model/App.php:834

反复查看以获得一个特定网站或商店所需的范围

iterate over to get the needed scope of one specific website or store

foreach (Mage::app()->getWebsites() as $website) {
    foreach ($website->getGroups() as $group) {
        $stores = $group->getStores();
        foreach ($stores as $store) {
            //$store is a store object
        }
    }
}

对于将来,如果您有类似的问题,这就是我如何在60秒内发现这些答案.首先,我使用grep表示方法名称或类似的方法名称,并在方法名称前加空格以查看方法的定义位置

For the future if you have similar questions here's how i discovered those answers within 60 seconds. First i grep for method names or similar method names with space before method name to see where the methods are defined

grep ' getStores' app/code -rsn 
grep ' getWebsites' app/code -rsn 

第二步是使用示例的grep,以查看核心开发人员如何使用它们.为此,我在grep中添加了> methodName,这为我提供了调用此方法的文件列表,这将使我们有地方查找示例:

Second step is grep for usage samples to see how they are meant to use by core developers. For that i add >methodName to grep and this gives me list of files where this method is called and this will give us place to look for examples:

grep '>getWebsites' app/code -rsn

这篇关于获取magento商店列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆