當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Varien_Simplexml_Element::asXml方法代碼示例

本文整理匯總了PHP中Varien_Simplexml_Element::asXml方法的典型用法代碼示例。如果您正苦於以下問題:PHP Varien_Simplexml_Element::asXml方法的具體用法?PHP Varien_Simplexml_Element::asXml怎麽用?PHP Varien_Simplexml_Element::asXml使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Varien_Simplexml_Element的用法示例。


在下文中一共展示了Varien_Simplexml_Element::asXml方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: 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

示例2: 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


注:本文中的Varien_Simplexml_Element::asXml方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。