当前位置: 首页>>代码示例>>PHP>>正文


PHP Mage_Core_Model_Config::setNode方法代码示例

本文整理汇总了PHP中Mage_Core_Model_Config::setNode方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Core_Model_Config::setNode方法的具体用法?PHP Mage_Core_Model_Config::setNode怎么用?PHP Mage_Core_Model_Config::setNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mage_Core_Model_Config的用法示例。


在下文中一共展示了Mage_Core_Model_Config::setNode方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: loadToXml

 /**
  * Load configuration values into xml config object
  *
  * @param Mage_Core_Model_Config $xmlConfig
  * @param string $condition
  * @return Mage_Core_Model_Resource_Config
  */
 public function loadToXml(Mage_Core_Model_Config $xmlConfig, $condition = null)
 {
     $read = $this->_getReadAdapter();
     if (!$read) {
         return $this;
     }
     $websites = array();
     $select = $read->select()->from($this->getTable('core_website'), array('website_id', 'code', 'name'));
     $rowset = $read->fetchAssoc($select);
     foreach ($rowset as $w) {
         $xmlConfig->setNode('websites/' . $w['code'] . '/system/website/id', $w['website_id']);
         $xmlConfig->setNode('websites/' . $w['code'] . '/system/website/name', $w['name']);
         $websites[$w['website_id']] = array('code' => $w['code']);
     }
     $stores = array();
     $select = $read->select()->from($this->getTable('core_store'), array('store_id', 'code', 'name', 'website_id'))->order('sort_order ' . Varien_Db_Select::SQL_ASC);
     $rowset = $read->fetchAssoc($select);
     foreach ($rowset as $s) {
         if (!isset($websites[$s['website_id']])) {
             continue;
         }
         $xmlConfig->setNode('stores/' . $s['code'] . '/system/store/id', $s['store_id']);
         $xmlConfig->setNode('stores/' . $s['code'] . '/system/store/name', $s['name']);
         $xmlConfig->setNode('stores/' . $s['code'] . '/system/website/id', $s['website_id']);
         $xmlConfig->setNode('websites/' . $websites[$s['website_id']]['code'] . '/system/stores/' . $s['code'], $s['store_id']);
         $stores[$s['store_id']] = array('code' => $s['code']);
         $websites[$s['website_id']]['stores'][$s['store_id']] = $s['code'];
     }
     $substFrom = array();
     $substTo = array();
     // load all configuration records from database, which are not inherited
     $select = $read->select()->from($this->getMainTable(), array('scope', 'scope_id', 'path', 'value'));
     if (!is_null($condition)) {
         $select->where($condition);
     }
     $rowset = $read->fetchAll($select);
     // set default config values from database
     foreach ($rowset as $r) {
         if ($r['scope'] !== 'default') {
             continue;
         }
         $value = str_replace($substFrom, $substTo, $r['value']);
         $xmlConfig->setNode('default/' . $r['path'], $value);
     }
     // inherit default config values to all websites
     $extendSource = $xmlConfig->getNode('default');
     foreach ($websites as $id => $w) {
         $websiteNode = $xmlConfig->getNode('websites/' . $w['code']);
         $websiteNode->extend($extendSource);
     }
     $deleteWebsites = array();
     // set websites config values from database
     foreach ($rowset as $r) {
         if ($r['scope'] !== 'websites') {
             continue;
         }
         $value = str_replace($substFrom, $substTo, $r['value']);
         if (isset($websites[$r['scope_id']])) {
             $nodePath = sprintf('websites/%s/%s', $websites[$r['scope_id']]['code'], $r['path']);
             $xmlConfig->setNode($nodePath, $value);
         } else {
             $deleteWebsites[$r['scope_id']] = $r['scope_id'];
         }
     }
     // extend website config values to all associated stores
     foreach ($websites as $website) {
         $extendSource = $xmlConfig->getNode('websites/' . $website['code']);
         if (isset($website['stores'])) {
             foreach ($website['stores'] as $sCode) {
                 $storeNode = $xmlConfig->getNode('stores/' . $sCode);
                 /**
                  * $extendSource DO NOT need overwrite source
                  */
                 $storeNode->extend($extendSource, false);
             }
         }
     }
     $deleteStores = array();
     // set stores config values from database
     foreach ($rowset as $r) {
         if ($r['scope'] !== 'stores') {
             continue;
         }
         $value = str_replace($substFrom, $substTo, $r['value']);
         if (isset($stores[$r['scope_id']])) {
             $nodePath = sprintf('stores/%s/%s', $stores[$r['scope_id']]['code'], $r['path']);
             $xmlConfig->setNode($nodePath, $value);
         } else {
             $deleteStores[$r['scope_id']] = $r['scope_id'];
         }
     }
     if ($deleteWebsites) {
         $this->_getWriteAdapter()->delete($this->getMainTable(), array('scope = ?' => 'websites', 'scope_id IN(?)' => $deleteWebsites));
//.........这里部分代码省略.........
开发者ID:nemphys,项目名称:magento2,代码行数:101,代码来源:Config.php

示例2: loadToXml

 /**
  * Load configuration values into xml config object
  *
  * @param Mage_Core_Model_Config $xmlConfig
  * @param string $cond
  * @return Mage_Core_Model_Mysql4_Config_Collection
  */
 public function loadToXml(Mage_Core_Model_Config $xmlConfig, $cond = null)
 {
     $read = $this->_getReadAdapter();
     if (!$read) {
         return $this;
     }
     $websites = array();
     $rows = $read->fetchAssoc("select website_id, code, name from " . $this->getTable('website'));
     foreach ($rows as $w) {
         $xmlConfig->setNode('websites/' . $w['code'] . '/system/website/id', $w['website_id']);
         $xmlConfig->setNode('websites/' . $w['code'] . '/system/website/name', $w['name']);
         $websites[$w['website_id']] = array('code' => $w['code']);
     }
     $stores = array();
     $rows = $read->fetchAssoc("select store_id, code, name, website_id from " . $this->getTable('store') . " order by sort_order asc");
     foreach ($rows as $s) {
         if (!isset($websites[$s['website_id']])) {
             continue;
         }
         $xmlConfig->setNode('stores/' . $s['code'] . '/system/store/id', $s['store_id']);
         $xmlConfig->setNode('stores/' . $s['code'] . '/system/store/name', $s['name']);
         $xmlConfig->setNode('stores/' . $s['code'] . '/system/website/id', $s['website_id']);
         $xmlConfig->setNode('websites/' . $websites[$s['website_id']]['code'] . '/system/stores/' . $s['code'], $s['store_id']);
         $stores[$s['store_id']] = array('code' => $s['code']);
         $websites[$s['website_id']]['stores'][$s['store_id']] = $s['code'];
     }
     $subst_from = array();
     $subst_to = array();
     // load all configuration records from database, which are not inherited
     $rows = $read->fetchAll("select scope, scope_id, path, value from " . $this->getMainTable() . ($cond ? ' where ' . $cond : ''));
     // set default config values from database
     foreach ($rows as $r) {
         if ($r['scope'] !== 'default') {
             continue;
         }
         $value = str_replace($subst_from, $subst_to, $r['value']);
         $xmlConfig->setNode('default/' . $r['path'], $value);
     }
     // inherit default config values to all websites
     $extendSource = $xmlConfig->getNode('default');
     foreach ($websites as $id => $w) {
         $websiteNode = $xmlConfig->getNode('websites/' . $w['code']);
         $websiteNode->extend($extendSource);
     }
     $deleteWebsites = array();
     // set websites config values from database
     foreach ($rows as $r) {
         if ($r['scope'] !== 'websites') {
             continue;
         }
         $value = str_replace($subst_from, $subst_to, $r['value']);
         if (isset($websites[$r['scope_id']])) {
             $xmlConfig->setNode('websites/' . $websites[$r['scope_id']]['code'] . '/' . $r['path'], $value);
         } else {
             $deleteWebsites[$r['scope_id']] = $r['scope_id'];
         }
     }
     // extend website config values to all associated stores
     foreach ($websites as $website) {
         $extendSource = $xmlConfig->getNode('websites/' . $website['code']);
         if (isset($website['stores'])) {
             foreach ($website['stores'] as $sCode) {
                 $storeNode = $xmlConfig->getNode('stores/' . $sCode);
                 /**
                  * $extendSource DO NOT need overwrite source
                  */
                 $storeNode->extend($extendSource, false);
             }
         }
     }
     $deleteStores = array();
     // set stores config values from database
     foreach ($rows as $r) {
         if ($r['scope'] !== 'stores') {
             continue;
         }
         $value = str_replace($subst_from, $subst_to, $r['value']);
         if (isset($stores[$r['scope_id']])) {
             $xmlConfig->setNode('stores/' . $stores[$r['scope_id']]['code'] . '/' . $r['path'], $value);
         } else {
             $deleteStores[$r['scope_id']] = $r['scope_id'];
         }
     }
     if ($deleteWebsites) {
         $this->_getWriteAdapter()->delete($this->getMainTable(), array($this->_getWriteAdapter()->quoteInto('scope=?', 'websites'), $this->_getWriteAdapter()->quoteInto('scope_id IN(?)', $deleteWebsites)));
     }
     if ($deleteStores) {
         $this->_getWriteAdapter()->delete($this->getMainTable(), array($this->_getWriteAdapter()->quoteInto('scope=?', 'stores'), $this->_getWriteAdapter()->quoteInto('scope_id IN(?)', $deleteStores)));
     }
     return $this;
 }
开发者ID:votanlean,项目名称:Magento-Pruebas,代码行数:98,代码来源:Config.php

示例3: testClassNameRewrite

 /**
  * @dataProvider classNameRewriteDataProvider
  */
 public function testClassNameRewrite($originalClass, $expectedClass, $classNameGetter)
 {
     $this->_model->setNode("global/rewrites/{$originalClass}", $expectedClass);
     $this->assertEquals($expectedClass, $this->_model->{$classNameGetter}($originalClass));
 }
开发者ID:nemphys,项目名称:magento2,代码行数:8,代码来源:ConfigFactoryTest.php

示例4: loadToXml

 /**
  * Load configuration values into xml config object
  *
  * @param Mage_Core_Model_Config $xmlConfig
  * @param string $cond
  * @return Mage_Core_Model_Mysql4_Config_Collection
  */
 public function loadToXml(Mage_Core_Model_Config $xmlConfig, $cond = null)
 {
     $read = $this->_getReadAdapter();
     if (!$read) {
         return $this;
     }
     #$tables = $read->fetchAll("show tables like 'core_%'");
     #print_r($tables);
     // initialize websites config
     $websites = array();
     $rows = $read->fetchAssoc("select website_id, code, name from " . $this->getTable('website'));
     foreach ($rows as $w) {
         $xmlConfig->setNode('websites/' . $w['code'] . '/system/website/id', $w['website_id']);
         $xmlConfig->setNode('websites/' . $w['code'] . '/system/website/name', $w['name']);
         $websites[$w['website_id']] = array('code' => $w['code']);
     }
     // initialize stores config
     $stores = array();
     $rows = $read->fetchAssoc("select store_id, code, name, website_id from " . $this->getTable('store') . " order by sort_order asc");
     foreach ($rows as $s) {
         $xmlConfig->setNode('stores/' . $s['code'] . '/system/store/id', $s['store_id']);
         $xmlConfig->setNode('stores/' . $s['code'] . '/system/store/name', $s['name']);
         $xmlConfig->setNode('stores/' . $s['code'] . '/system/website/id', $s['website_id']);
         $xmlConfig->setNode('websites/' . $websites[$s['website_id']]['code'] . '/system/stores/' . $s['code'], $s['store_id']);
         $stores[$s['store_id']] = array('code' => $s['code']);
         $websites[$s['website_id']]['stores'][$s['store_id']] = $s['code'];
     }
     $subst_from = array();
     $subst_to = array();
     // get default distribution config vars
     /*
     $vars = Mage::getConfig()->getDistroServerVars();
     foreach ($vars as $k=>$v) {
         $subst_from[] = '{{'.$k.'}}';
         $subst_to[] = $v;
     }
     */
     // load all configuration records from database, which are not inherited
     $rows = $read->fetchAll("select scope, scope_id, path, value from " . $this->getMainTable() . ($cond ? ' where ' . $cond : ''));
     // set default config values from database
     foreach ($rows as $r) {
         if ($r['scope'] !== 'default') {
             continue;
         }
         $value = str_replace($subst_from, $subst_to, $r['value']);
         $xmlConfig->setNode('default/' . $r['path'], $value);
     }
     // inherit default config values to all websites
     $extendSource = $xmlConfig->getNode('default');
     foreach ($websites as $id => $w) {
         $websiteNode = $xmlConfig->getNode('websites/' . $w['code']);
         $websiteNode->extend($extendSource);
     }
     // set websites config values from database
     foreach ($rows as $r) {
         if ($r['scope'] !== 'websites') {
             continue;
         }
         $value = str_replace($subst_from, $subst_to, $r['value']);
         $xmlConfig->setNode('websites/' . $websites[$r['scope_id']]['code'] . '/' . $r['path'], $value);
     }
     // extend website config values to all associated stores
     foreach ($websites as $wId => $website) {
         $extendSource = $xmlConfig->getNode('websites/' . $website['code']);
         if (isset($website['stores'])) {
             foreach ($website['stores'] as $sId => $sCode) {
                 $storeNode = $xmlConfig->getNode('stores/' . $sCode);
                 $storeNode->extend($extendSource);
             }
         }
     }
     // set stores config values from database
     foreach ($rows as $r) {
         if ($r['scope'] !== 'stores') {
             continue;
         }
         $value = str_replace($subst_from, $subst_to, $r['value']);
         $xmlConfig->setNode('stores/' . $stores[$r['scope_id']]['code'] . '/' . $r['path'], $value);
     }
     #echo "<xmp>".$xmlConfig->getNode()->asNiceXml()."</xmp>"; exit;
     return $this;
 }
开发者ID:arslbbt,项目名称:mangentovies,代码行数:89,代码来源:Config.php


注:本文中的Mage_Core_Model_Config::setNode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。