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


PHP Varien_Simplexml_Element::addChild方法代码示例

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


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

示例1: generateXml

 /**
  * Generate sitemap xml
  *
  * @return string
  */
 public function generateXml()
 {
     $storeId = $this->getStoreId();
     $date = date('Y-m-d');
     $simplexml = new Varien_Simplexml_Element('<?xml version="1.0" encoding="UTF-8"?><urlset></urlset>');
     $simplexml->addAttribute('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9');
     /**
      * Generate categories sitemap
      */
     $changefreq = (string) Mage::getStoreConfig('sitemap/category/changefreq');
     $priority = (string) Mage::getStoreConfig('sitemap/category/priority');
     $categories = Mage::getModel('catalog/category')->setStoreId($storeId)->getCollection()->addAttributeToSelect('*')->load();
     foreach ($categories as $category) {
         $category = Mage::getModel('catalog/category')->load($category->getId());
         if (!$category->getIsActive()) {
             continue;
         }
         $url = $simplexml->addChild('url');
         $url->addChild('loc', $category->getCategoryUrl());
         $url->addChild('lastmod', $date);
         $url->addChild('changefreq', $changefreq);
         $url->addChild('priority', $priority);
     }
     /**
      * Generate products sitemap
      */
     $changefreq = (string) Mage::getStoreConfig('sitemap/product/changefreq');
     $priority = (string) Mage::getStoreConfig('sitemap/product/priority');
     $products = Mage::getModel('catalog/product')->setStoreId($storeId)->getCollection()->addAttributeToSelect('*');
     Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($products);
     Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($products);
     $products->load();
     foreach ($products as $product) {
         $product = Mage::getModel('catalog/product')->load($product->getId());
         $url = $simplexml->addChild('url');
         $url->addChild('loc', $product->getProductUrl());
         $url->addChild('lastmod', $date);
         $url->addChild('changefreq', $changefreq);
         $url->addChild('priority', $priority);
     }
     /**
      * Generate CMS pages sitemap
      */
     $changefreq = (string) Mage::getStoreConfig('sitemap/page/changefreq');
     $priority = (string) Mage::getStoreConfig('sitemap/page/priority');
     $pages = Mage::getModel('cms/page')->setStoreId($storeId)->getCollection();
     foreach ($pages as $page) {
         $page = Mage::getModel('cms/page')->load($page->getId());
         $url = $simplexml->addChild('url');
         $url->addChild('loc', Mage::getBaseUrl() . $page->getIdentifier());
         $url->addChild('lastmod', $date);
         $url->addChild('changefreq', $changefreq);
         $url->addChild('priority', $priority);
     }
     // record last generation time
     $this->setSitemapTime(now());
     $this->save();
     return $simplexml->asXml();
 }
开发者ID:arslbbt,项目名称:mangentovies,代码行数:64,代码来源:Sitemap.php

示例2: getData

 public function getData()
 {
     $xml = new \Varien_Simplexml_Element('<config></config>');
     $defaultNode = $xml->addChild('global')->addChild('limesoda')->addChild('environments')->addChild('default');
     foreach ($this->_collection as $item) {
         /** @var $item \Mage_Core_Model_Config_Data */
         $defaultNode->addChild($this->_getNodeName($item), $this->_getNodeValue($item));
     }
     return $xml->asXML();
 }
开发者ID:ktomk,项目名称:HarrisStreet-ImpEx,代码行数:10,代码来源:LimeSodaXml.php

示例3: updateMenu

 public function updateMenu(Varien_Simplexml_Element $node)
 {
     $entityTypesCollection = $this->_getEntityTypesCollection();
     if ($entityTypesCollection->getSize()) {
         $children = $node->addChild('children');
         $index = 0;
         foreach ($entityTypesCollection as $entityType) {
             $index += 10;
             $menuItem = $children->addChild(sprintf('goodahead_etm_entity_type_%d', $entityType->getId()));
             $menuItem->addChild('title', strlen($entityType->getEntityTypeName()) ? $entityType->getEntityTypeName() : $entityType->getEntityTypeCode());
             $menuItem->addChild('sort_order', $index);
             $menuItem->addChild('action', sprintf((string) $node->base_link, $entityType->getId()));
         }
     } else {
         $nodeName = $node->getName();
         unset($node->getParent()->{$nodeName});
     }
 }
开发者ID:eniuz,项目名称:entitytype-manager,代码行数:18,代码来源:Data.php

示例4: saveSurchargeXmlToSession

 public function saveSurchargeXmlToSession($address, $surcharge_config)
 {
     $_xml = null;
     //Do nothing if no cards are configured for surcharge
     if ($surcharge_config && count($surcharge_config)) {
         $xml = new Varien_Simplexml_Element('<surcharges />');
         $quote = $address->getQuote();
         $store = $quote->getStore();
         $shipping = $address->getShippingAmount();
         foreach ($surcharge_config as $rule) {
             if ((string) $quote->getPayment()->getConfigData('trncurrency') == 'store') {
                 $chargeAmountNoTax = $address->getSubtotal();
             } else {
                 $chargeAmountNoTax = $address->getBaseSubtotal();
             }
             //Apply TAX if applies
             $taxClassId = (int) Mage::getStoreConfig('payment/sagepaysuite/surcharge_taxclass', $store);
             $tax_percent = 0;
             if ($taxClassId !== 0) {
                 $trequest = Mage::getSingleton('tax/calculation')->getRateRequest($quote->getBillingAddress(), $quote->getShippingAddress(), FALSE, $store);
                 $tax_percent = Mage::getSingleton('tax/calculation')->getRate($trequest->setProductClassId($taxClassId));
             }
             if ($rule['chargetype'] == 'fixed') {
                 $amount = $rule['amount'];
             } else {
                 //Percent
                 $amount = $rule['amount'] * ($chargeAmountNoTax + $shipping + $address->getTaxAmount()) / 100;
             }
             //Adding TAX
             if ($tax_percent) {
                 $chargeTaxAmount = $tax_percent * $amount / 100;
                 $amount = $amount + $chargeTaxAmount;
             }
             $amount = number_format($amount, 2, '.', '');
             //force all to fixed amount
             $rule['chargetype'] = "fixed";
             $nodi = $xml->addChild('surcharge', '');
             $nodi->addChild('paymentType', $rule['creditcard']);
             $nodi->addChild($rule['chargetype'], $amount);
         }
         $_xml = str_replace("\n", "", trim($xml->asXml()));
     }
     Mage::getSingleton('sagepaysuite/session')->setSurchargeXml($_xml);
 }
开发者ID:GaynorH,项目名称:prestigedrinks,代码行数:44,代码来源:Data.php

示例5: addFrontendParams

 /**
  * Add frontend params to attribute node
  *
  * @param array $attribute
  * @param Varien_Simplexml_Element $itemXml
  */
 public function addFrontendParams($attribute, $itemXml)
 {
     if (isset($attribute['frontend']) && is_array($attribute['frontend'])) {
         $paramXml = $itemXml->addChild('frontend');
         foreach ($attribute['frontend'] as $param => $value) {
             $paramXml->addChild($param, $value);
         }
     }
 }
开发者ID:QiuLihua83,项目名称:magento-enterprise-1.13.1.0,代码行数:15,代码来源:Processor.php

示例6: _getChildByHandle

 /**
  * Get child by handle
  *
  * @param Varien_Simplexml_Element $xmlObject
  * @param string $handle
  * @return Varien_Simplexml_Element
  */
 protected function _getChildByHandle($xmlObject, $handle)
 {
     foreach ($xmlObject->children() as $child) {
         if ($child->getName() == $handle) {
             return $child;
         }
     }
     return $xmlObject->addChild($handle);
 }
开发者ID:rorteg,项目名称:magento2,代码行数:16,代码来源:Collection.php

示例7: _changeBuiltInTestStatus

 /**
  * Changes extension suite internal tests status
  *
  * @param bool $status
  */
 protected function _changeBuiltInTestStatus($status)
 {
     if (!file_exists($this->getArg('project') . '/app/etc/modules/EcomDev_PHPUnitTest.xml')) {
         die('Cannot find EcomDev_PHPUnitTest.xml file in app/etc/modules directory');
     }
     $disableFile = $this->getArg('project') . '/app/etc/modules/ZDisable_EcomDev_PHPUnitTest.xml';
     if ($status && file_exists($disableFile)) {
         unlink($disableFile);
     } elseif (!$status && !file_exists($disableFile)) {
         $fileContent = new Varien_Simplexml_Element('<config />');
         $fileContent->addChild('modules')->addChild('EcomDev_PHPUnitTest')->addChild('active', 'false');
         $fileContent->asNiceXml($disableFile);
     }
 }
开发者ID:tiagosampaio,项目名称:EcomDev_PHPUnit,代码行数:19,代码来源:ecomdev-phpunit.php


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