如何通过在magento中使用基本URL来获取商店ID

时间:2016-12-01 07:49:45

标签: php magento-1.7

我有一个基本网址,我想从<configuration> <property> <name>yarn.resourcemanager.connect.retry-interval.ms</name> <value>2000</value> </property> <property> <name>yarn.resourcemanager.ha.enabled</name> <value>true</value> </property> <property> <name>yarn.resourcemanager.ha.automatic-failover.enabled</name> <value>true</value> </property> <property> <name>yarn.resourcemanager.ha.automatic-failover.embedded</name> <value>true</value> </property> <property> <name>yarn.resourcemanager.cluster-id</name> <value>yarn-cluster</value> </property> <property> <name>yarn.resourcemanager.ha.rm-ids</name> <value>rm1,rm2</value> </property> <property> <name>yarn.resourcemanager.ha.id</name> <value>rm1</value> </property> <property> <name>yarn.resourcemanager.scheduler.class</name> <value>org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FairScheduler</value> </property> <property> <name>yarn.resourcemanager.recovery.enabled</name> <value>true</value> </property> <property> <name>yarn.resourcemanager.store.class</name> <value>org.apache.hadoop.yarn.server.resourcemanager.recovery.ZKRMStateStore</value> </property> <property> <name>yarn.resourcemanager.zk-address</name> <value>master:2181,slave1:2181,slave2:2181</value> </property> <property> <name>yarn.app.mapreduce.am.scheduler.connection.wait.interval-ms</name> <value>5000</value> </property> <property> <name>yarn.resourcemanager.work-preserving-recovery.enabled</name> <value>true</value> </property> <property> <name>yarn.resourcemanager.address.rm1</name> <value>master:23140</value> </property> <property> <name>yarn.resourcemanager.scheduler.address.rm1</name> <value>master:23130</value> </property> <property> <name>yarn.resourcemanager.webapp.https.address.rm1</name> <value>master:23189</value> </property> <property> <name>yarn.resourcemanager.webapp.address.rm1</name> <value>master:23188</value> </property> <property> <name>yarn.resourcemanager.resource-tracker.address.rm1</name> <value>master:23125</value> </property> <property> <name>yarn.resourcemanager.admin.address.rm1</name> <value>master:23141</value> </property> <property> <name>yarn.resourcemanager.address.rm2</name> <value>slave1:23140</value> </property> <property> <name>yarn.resourcemanager.scheduler.address.rm2</name> <value>slave1:23130</value> </property> <property> <name>yarn.resourcemanager.webapp.https.address.rm2</name> <value>slave1:23189</value> </property> <property> <name>yarn.resourcemanager.webapp.address.rm2</name> <value>slave1:23188</value> </property> <property> <name>yarn.resourcemanager.resource-tracker.address.rm2</name> <value>slave1:23125</value> </property> <property> <name>yarn.resourcemanager.admin.address.rm2</name> <value>slave1:23141</value> </property> <property> <description>Address where the localizer IPC is.</description> <name>yarn.nodemanager.localizer.address</name> <value>0.0.0.0:23344</value> </property> <property> <description>NM Webapp address.</description> <name>yarn.nodemanager.webapp.address</name> <value>0.0.0.0:23999</value> </property> <property> <name>yarn.nodemanager.aux-services</name> <value>mapreduce_shuffle</value> </property> <property> <name>yarn.nodemanager.local-dirs</name> <value>/tmp/pseudo-dist/yarn/local</value> </property> <property> <name>yarn.nodemanager.log-dirs</name> <value>/tmp/pseudo-dist/yarn/log</value> </property> <property> <name>mapreduce.shuffle.port</name> <value>23080</value> </property> <property> <name>yarn.resourcemanager.work-preserving-recovery.enabled</name> <value>true</value> </property> </configuration> 获得storeId 我怎么能得到这个?

我的代码:

baseUrl

我需要将ID存储在$baseUrl ="http://marketplace.computenext.com"; $storeId = ""; 变量中。

2 个答案:

答案 0 :(得分:0)

试试这个,

// Gets the current store's details
$store = Mage::app()->getStore();

// Gets the current store's id
$storeId = Mage::app()->getStore()->getStoreId();

答案 1 :(得分:0)

这样您就可以收到第一个带有所需网址的商店(id):

<?php
require_once 'app/Mage.php';
Mage::app("admin");

$stores = Mage::getModel('core/store')->getCollection()->getItems();
$baseUrl = 'http://your.url.here.com/';
$searchableStoreId = null;
foreach ($stores as $storeId => $store) {
    $currentStoreUnsecureUrl = Mage::getStoreConfig('web/unsecure/base_url', $storeId);
    $currentStoreSecureUrl = Mage::getStoreConfig('web/secure/base_url', $storeId);
    if ($currentStoreUnsecureUrl == $baseUrl || $currentStoreSecureUrl == $baseUrl) {
        $searchableStoreId = $storeId;
        continue;
    }
}

echo $searchableStoreId; // int store id here or NULL