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


PHP Mage_XmlConnect_Model_Simplexml_Element::addChild方法代码示例

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


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

示例1: _toHtml

 /**
  * Render shipping methods xml
  *
  * @return string
  */
 protected function _toHtml()
 {
     $methodsXmlObj = new Mage_XmlConnect_Model_Simplexml_Element('<shipping_methods></shipping_methods>');
     $_shippingRateGroups = $this->getShippingRates();
     if ($_shippingRateGroups) {
         $store = $this->getQuote()->getStore();
         $_sole = count($_shippingRateGroups) == 1;
         foreach ($_shippingRateGroups as $code => $_rates) {
             $methodXmlObj = $methodsXmlObj->addChild('method');
             $methodXmlObj->addAttribute('label', $methodsXmlObj->xmlentities(strip_tags($this->getCarrierName($code))));
             $ratesXmlObj = $methodXmlObj->addChild('rates');
             $_sole = $_sole && count($_rates) == 1;
             foreach ($_rates as $_rate) {
                 $rateXmlObj = $ratesXmlObj->addChild('rate');
                 $rateXmlObj->addAttribute('label', $methodsXmlObj->xmlentities(strip_tags($_rate->getMethodTitle())));
                 $rateXmlObj->addAttribute('code', $_rate->getCode());
                 if ($_rate->getErrorMessage()) {
                     $rateXmlObj->addChild('error_message', $methodsXmlObj->xmlentities(strip_tags($_rate->getErrorMessage())));
                 } else {
                     $price = Mage::helper('tax')->getShippingPrice($_rate->getPrice(), Mage::helper('tax')->displayShippingPriceIncludingTax(), $this->getAddress());
                     $formattedPrice = $store->convertPrice($price, true, false);
                     $rateXmlObj->addAttribute('price', Mage::helper('xmlconnect')->formatPriceForXml($store->convertPrice($price, false, false)));
                     $rateXmlObj->addAttribute('formated_price', $formattedPrice);
                 }
             }
         }
     } else {
         Mage::throwException($this->__('Sorry, no quotes are available for this order at this time.'));
     }
     return $methodsXmlObj->asNiceXml();
 }
开发者ID:votanlean,项目名称:Magento-Pruebas,代码行数:36,代码来源:Avaliable.php

示例2: addTotalsToXmlObject

 /**
  * Add order totals rendered to XML object
  * (get from template: sales/order/totals.phtml)
  *
  * @param Mage_XmlConnect_Model_Simplexml_Element $orderXmlObj
  * @return null
  */
 public function addTotalsToXmlObject(Mage_XmlConnect_Model_Simplexml_Element $orderXmlObj)
 {
     // all Enterprise renderers from layout update into array an realize checking of their using
     $enterpriseBlocks = array('reward.sales.order.total' => array('module' => 'Enterprise_Reward', 'block' => 'enterprise_reward/sales_order_total'), 'customerbalance' => array('module' => 'Enterprise_CustomerBalance', 'block' => 'xmlconnect/customer_order_totals_customerbalance', 'template' => 'customerbalance/order/customerbalance.phtml'), 'customerbalance_total_refunded' => array('module' => 'Enterprise_CustomerBalance', 'block' => 'xmlconnect/customer_order_totals_customerbalance_refunded', 'template' => 'customerbalance/order/customerbalance_refunded.phtml', 'after' => '-', 'action' => array('method' => 'setAfterTotal', 'value' => 'grand_total')), 'giftwrapping' => array('module' => 'Enterprise_GiftWrapping', 'block' => 'enterprise_giftwrapping/sales_totals'), 'giftcards' => array('module' => 'Enterprise_GiftCardAccount', 'block' => 'xmlconnect/customer_order_totals_giftcards', 'template' => 'giftcardaccount/order/giftcards.phtml'));
     foreach ($enterpriseBlocks as $name => $block) {
         // create blocks only for Enterprise/Pro modules which is in system
         if (is_object(Mage::getConfig()->getNode('modules/' . $block['module']))) {
             $blockInstance = $this->getLayout()->createBlock($block['block'], $name);
             $this->setChild($name, $blockInstance);
             if (isset($block['action']['method']) && isset($block['action']['value'])) {
                 $method = $block['action']['method'];
                 $blockInstance->{$method}($block['action']['value']);
             }
         }
     }
     $this->_beforeToHtml();
     $totalsXml = $orderXmlObj->addChild('totals');
     foreach ($this->getTotals() as $total) {
         if ($total->getValue()) {
             $total->setValue(strip_tags($total->getValue()));
         }
         if ($total->getBlockName()) {
             $block = $this->getLayout()->getBlock($total->getBlockName());
             if (is_object($block)) {
                 if (method_exists($block, 'addToXmlObject')) {
                     $block->setTotal($total)->addToXmlObject($totalsXml);
                 } else {
                     $this->_addTotalToXml($total, $totalsXml);
                 }
             }
         } else {
             $this->_addTotalToXml($total, $totalsXml);
         }
     }
 }
开发者ID:hazaeluz,项目名称:magento_connect,代码行数:42,代码来源:Totals.php

示例3: _toHtml

 /**
  * Generate images gallery xml
  *
  * @return string
  */
 protected function _toHtml()
 {
     $productId = $this->getRequest()->getParam('id', null);
     $product = Mage::getModel('catalog/product')->setStoreId(Mage::app()->getStore()->getId())->load($productId);
     $collection = $product->getMediaGalleryImages();
     $imagesNode = new Mage_XmlConnect_Model_Simplexml_Element('<images></images>');
     $helper = $this->helper('catalog/image');
     foreach ($collection as $item) {
         $imageNode = $imagesNode->addChild('image');
         /**
          * Big image
          */
         $bigImage = $helper->init($product, 'image', $item->getFile())->resize(Mage::helper('xmlconnect/image')->getImageSizeForContent('product_gallery_big'));
         $fileNode = $imageNode->addChild('file');
         $fileNode->addAttribute('type', 'big');
         $fileNode->addAttribute('url', $bigImage);
         $file = Mage::helper('xmlconnect')->urlToPath($bigImage);
         $fileNode->addAttribute('id', ($id = $item->getId()) ? (int) $id : 0);
         $fileNode->addAttribute('modification_time', filemtime($file));
         /**
          * Small image
          */
         $smallImage = $helper->init($product, 'thumbnail', $item->getFile())->resize(Mage::helper('xmlconnect/image')->getImageSizeForContent('product_gallery_small'));
         $fileNode = $imageNode->addChild('file');
         $fileNode->addAttribute('type', 'small');
         $fileNode->addAttribute('url', $smallImage);
         $file = Mage::helper('xmlconnect')->urlToPath($smallImage);
         $fileNode->addAttribute('modification_time', filemtime($file));
     }
     return $imagesNode->asNiceXml();
 }
开发者ID:votanlean,项目名称:Magento-Pruebas,代码行数:36,代码来源:Gallery.php

示例4: _toHtml

 /**
  * Render cross sell items xml
  *
  * @return string
  */
 protected function _toHtml()
 {
     $crossSellXmlObj = new Mage_XmlConnect_Model_Simplexml_Element('<crosssell></crosssell>');
     if (!$this->getItemCount()) {
         return $crossSellXmlObj->asNiceXml();
     }
     foreach ($this->getItems() as $_item) {
         $itemXmlObj = $crossSellXmlObj->addChild('item');
         $itemXmlObj->addChild('name', $crossSellXmlObj->xmlentities(strip_tags($_item->getName())));
         $icon = $this->helper('catalog/image')->init($_item, 'thumbnail')->resize(Mage::helper('xmlconnect/image')->getImageSizeForContent('product_small'));
         $iconXml = $itemXmlObj->addChild('icon', $icon);
         $file = Mage::helper('xmlconnect')->urlToPath($icon);
         $iconXml->addAttribute('modification_time', filemtime($file));
         $itemXmlObj->addChild('entity_id', $_item->getId());
         $itemXmlObj->addChild('entity_type', $_item->getTypeId());
         $itemXmlObj->addChild('has_options', (int) $_item->getHasOptions());
         if ($this->getChild('product_price')) {
             $this->getChild('product_price')->setProduct($_item)->setProductXmlObj($itemXmlObj)->collectProductPrices();
         }
         if (!$_item->getRatingSummary()) {
             Mage::getModel('review/review')->getEntitySummary($_item, Mage::app()->getStore()->getId());
         }
         $itemXmlObj->addChild('rating_summary', round((int) $_item->getRatingSummary()->getRatingSummary() / 10));
         $itemXmlObj->addChild('reviews_count', $_item->getRatingSummary()->getReviewsCount());
     }
     return $crossSellXmlObj->asNiceXml();
 }
开发者ID:votanlean,项目名称:Magento-Pruebas,代码行数:32,代码来源:Crosssell.php

示例5: addPaymentFormToXmlObj

    /**
     * Add cc save payment method form to payment XML object
     *
     * @param Mage_XmlConnect_Model_Simplexml_Element $paymentItemXmlObj
     * @return Mage_XmlConnect_Model_Simplexml_Element
     */
    public function addPaymentFormToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $paymentItemXmlObj)
    {
        $helper = Mage::helper('xmlconnect');
        $method = $this->getMethod();
        if (!$method) {
            return $paymentItemXmlObj;
        }
        $formXmlObj = $paymentItemXmlObj->addChild('form');
        $formXmlObj->addAttribute('name', 'payment_form_' . $method->getCode());
        $formXmlObj->addAttribute('method', 'post');
        $owner = $this->getInfoData('cc_owner');
        $ccTypes = $helper->getArrayAsXmlItemValues($this->getCcAvailableTypes(), $this->getInfoData('cc_type'));
        $ccMonthArray = $this->getCcMonths();
        $ccMonths = $helper->getArrayAsXmlItemValues($ccMonthArray, $this->getInfoData('cc_exp_month'));
        $ccYears = $helper->getArrayAsXmlItemValues($this->getCcYears(), $this->getInfoData('cc_exp_year'));
        $verification = '';
        if ($this->hasVerification()) {
            $verification = '<field name="payment[cc_cid]" type="text" label="' . $this->__('Card Verification Number') . '" required="true">
                <validators>
                    <validator relation="payment[cc_type]" type="credit_card_svn" message="' . $this->__('Card verification number is wrong') . '"/>
                </validators>
            </field>';
        }
        $solo = '';
        if ($this->hasSsCardType()) {
            $ssCcMonths = $helper->getArrayAsXmlItemValues($ccMonthArray, $this->getInfoData('cc_ss_start_month'));
            $ssCcYears = $helper->getArrayAsXmlItemValues($this->getSsStartYears(), $this->getInfoData('cc_ss_start_year'));
            $solo = $helper->getSoloXml($ssCcMonths, $ssCcYears);
        }
        $xml = <<<EOT
    <fieldset>
        <field name="payment[cc_owner]" type="text" label="{$this->__('Name on Card')}" value="{$owner}" required="true" />
        <field name="payment[cc_type]" type="select" label="{$this->__('Credit Card Type')}" required="true">
            <values>
                {$ccTypes}
            </values>
            {$solo}
        </field>
        <field name="payment[cc_number]" type="text" label="{$this->__('Credit Card Number')}" required="true">
            <validators>
                <validator relation="payment[cc_type]" type="credit_card" message="{$this->__('Credit card number does not match credit card type.')}"/>
            </validators>
        </field>
        <field name="payment[cc_exp_month]" type="select" label="{$this->__('Expiration Date - Month')}" required="true">
            <values>
                {$ccMonths}
            </values>
        </field>
        <field name="payment[cc_exp_year]" type="select" label="{$this->__('Expiration Date - Year')}" required="true">
            <values>
                {$ccYears}
            </values>
        </field>
        {$verification}
    </fieldset>
EOT;
        $fieldsetXmlObj = Mage::getModel('xmlconnect/simplexml_element', $xml);
        $formXmlObj->appendChild($fieldsetXmlObj);
    }
开发者ID:SalesOneGit,项目名称:s1_magento,代码行数:65,代码来源:Ccsave.php

示例6: _toHtml

 /**
  * Render cart summary xml
  *
  * @return string
  */
 protected function _toHtml()
 {
     $quote = $this->getQuote();
     $xmlObject = new Mage_XmlConnect_Model_Simplexml_Element('<cart></cart>');
     $xmlObject->addChild('is_virtual', (int) $this->helper('checkout/cart')->getIsVirtualQuote());
     $xmlObject->addChild('summary_qty', (int) $this->helper('checkout/cart')->getSummaryCount());
     $xmlObject->addChild('virtual_qty', (int) $quote->getItemVirtualQty());
     if (strlen($quote->getCouponCode())) {
         $xmlObject->addChild('has_coupon_code', 1);
     }
     $totalsXml = $this->getChildHtml('totals');
     if ($totalsXml) {
         $totalsXmlObj = new Mage_XmlConnect_Model_Simplexml_Element($totalsXml);
         $xmlObject->appendChild($totalsXmlObj);
     }
     return $xmlObject->asNiceXml();
 }
开发者ID:votanlean,项目名称:Magento-Pruebas,代码行数:22,代码来源:Info.php

示例7: _toHtml

 /**
  * Render customer wishlist xml
  *
  * @return string
  */
 protected function _toHtml()
 {
     $wishlistXmlObj = new Mage_XmlConnect_Model_Simplexml_Element('<wishlist></wishlist>');
     $hasMoreItems = 0;
     /**
      * Apply offset and count
      */
     $request = $this->getRequest();
     $offset = (int) $request->getParam('offset', 0);
     $count = (int) $request->getParam('count', 0);
     $count = $count <= 0 ? 1 : $count;
     if ($offset + $count < $this->getWishlistItems()->getSize()) {
         $hasMoreItems = 1;
     }
     $this->getWishlistItems()->getSelect()->limit($count, $offset);
     $wishlistXmlObj->addAttribute('items_count', $this->getWishlistItemsCount());
     $wishlistXmlObj->addAttribute('has_more_items', $hasMoreItems);
     if ($this->hasWishlistItems()) {
         /**
          * @var Mage_Wishlist_Model_Mysql4_Product_Collection
          */
         foreach ($this->getWishlistItems() as $item) {
             $itemXmlObj = $wishlistXmlObj->addChild('item');
             $itemXmlObj->addChild('item_id', $item->getWishlistItemId());
             $itemXmlObj->addChild('entity_id', $item->getProductId());
             $itemXmlObj->addChild('entity_type_id', $item->getProduct()->getTypeId());
             $itemXmlObj->addChild('name', $wishlistXmlObj->xmlentities(strip_tags($item->getName())));
             $itemXmlObj->addChild('in_stock', (int) $item->getProduct()->isInStock());
             $itemXmlObj->addChild('is_salable', (int) $item->getProduct()->getIsSalable());
             /**
              * If product type is grouped than it has options as its grouped items
              */
             if ($item->getProduct()->getTypeId() == Mage_Catalog_Model_Product_Type_Grouped::TYPE_CODE) {
                 $item->setHasOptions(true);
             }
             $itemXmlObj->addChild('has_options', (int) $item->getHasOptions());
             $icon = $this->helper('catalog/image')->init($item->getProduct(), 'small_image')->resize(Mage::helper('xmlconnect/image')->getImageSizeForContent('product_small'));
             $iconXml = $itemXmlObj->addChild('icon', $icon);
             $file = Mage::helper('xmlconnect')->urlToPath($icon);
             $iconXml->addAttribute('modification_time', filemtime($file));
             $description = $wishlistXmlObj->xmlentities(strip_tags($item->getDescription()));
             $itemXmlObj->addChild('description', $description);
             $addedDate = $wishlistXmlObj->xmlentities($this->getFormatedDate($item->getAddedAt()));
             $itemXmlObj->addChild('added_date', $addedDate);
             if ($this->getChild('product_price')) {
                 $this->getChild('product_price')->setProduct($item->getProduct())->setProductXmlObj($itemXmlObj)->collectProductPrices();
             }
             if (!$item->getProduct()->getRatingSummary()) {
                 Mage::getModel('review/review')->getEntitySummary($item->getProduct(), Mage::app()->getStore()->getId());
             }
             $ratingSummary = (int) $item->getProduct()->getRatingSummary()->getRatingSummary();
             $itemXmlObj->addChild('rating_summary', round($ratingSummary / 10));
             $itemXmlObj->addChild('reviews_count', $item->getProduct()->getRatingSummary()->getReviewsCount());
         }
     }
     return $wishlistXmlObj->asNiceXml();
 }
开发者ID:xiaoguizhidao,项目名称:emporiodopara,代码行数:62,代码来源:Wishlist.php

示例8: addDetailsToXmlObj

 /**
  * Add cart details to XML object
  *
  * @param Mage_XmlConnect_Model_Simplexml_Element $reviewXmlObj
  * @return Mage_XmlConnect_Model_Simplexml_Element
  */
 public function addDetailsToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $reviewXmlObj)
 {
     $itemsXmlObj = $reviewXmlObj->addChild('ordered_items');
     foreach ($this->getItems() as $item) {
         $this->getItemXml($item, $itemsXmlObj);
     }
     $reviewXmlObj->appendChild($this->getChild('totals')->setReturnObjectFlag(true)->_toHtml());
     return $reviewXmlObj;
 }
开发者ID:QiuLihua83,项目名称:magento-enterprise-1.13.1.0,代码行数:15,代码来源:Details.php

示例9: _toHtml

 /**
  * Render cart totals xml
  *
  * @return string
  */
 protected function _toHtml()
 {
     $paypalCart = Mage::getModel('paypal/cart', array($this->getQuote()));
     $totalsXmlObj = new Mage_XmlConnect_Model_Simplexml_Element('<cart_totals></cart_totals>');
     foreach ($paypalCart->getTotals(true) as $code => $amount) {
         $currencyAmount = $this->helper('core')->currency($amount, false, false);
         $totalsXmlObj->addChild($code, sprintf('%01.2F', $currencyAmount));
     }
     return $totalsXmlObj->asNiceXml();
 }
开发者ID:xiaoguizhidao,项目名称:emporiodopara,代码行数:15,代码来源:Totals.php

示例10: _toHtml

 /**
  * Render home category list xml
  *
  * @return string
  */
 protected function _toHtml()
 {
     $homeXmlObj = new Mage_XmlConnect_Model_Simplexml_Element('<home></home>');
     $categoryCollection = Mage::getResourceModel('xmlconnect/category_collection');
     $categoryCollection->setStoreId(Mage::app()->getStore()->getId())->addParentIdFilter(Mage::app()->getStore()->getRootCategoryId())->setOrder('position', 'ASC')->setLimit(0, self::HOME_PAGE_CATEGORIES_COUNT);
     if (sizeof($categoryCollection)) {
         $itemsXmlObj = $homeXmlObj->addChild('categories');
     }
     foreach ($categoryCollection->getItems() as $item) {
         $itemXmlObj = $itemsXmlObj->addChild('item');
         $itemXmlObj->addChild('label', $homeXmlObj->xmlentities(strip_tags($item->getName())));
         $itemXmlObj->addChild('entity_id', $item->getEntityId());
         $itemXmlObj->addChild('content_type', $item->hasChildren() ? 'categories' : 'products');
         $icon = Mage::helper('xmlconnect/catalog_category_image')->initialize($item, 'thumbnail')->resize(Mage::helper('xmlconnect/image')->getImageSizeForContent('category'));
         $iconXml = $itemXmlObj->addChild('icon', $icon);
         $file = Mage::helper('xmlconnect')->urlToPath($icon);
         $iconXml->addAttribute('modification_time', filemtime($file));
     }
     $homeXmlObj->addChild('home_banner', '/current/media/catalog/category/banner_home.png');
     return $homeXmlObj->asNiceXml();
 }
开发者ID:votanlean,项目名称:Magento-Pruebas,代码行数:26,代码来源:Home.php

示例11: collectProductPrices

 /**
  * Collect product prices to specified item xml object
  *
  * @param Mage_Catalog_Model_Product $product
  * @param Mage_XmlConnect_Model_Simplexml_Element $item
  */
 public function collectProductPrices(Mage_Catalog_Model_Product $product, Mage_XmlConnect_Model_Simplexml_Element $item)
 {
     $this->setProduct($product);
     if ($product->getCanShowPrice() !== false) {
         $priceXmlObj = $item->addChild('price');
         if (($_min = $this->getMinAmount()) && ($_max = $this->getMaxAmount()) && $_min == $_max) {
             $priceXmlObj->addAttribute('regular', Mage::helper('core')->currency($_min, true, false));
         } elseif (($_min = $this->getMinAmount()) && $_min != 0) {
             $priceXmlObj->addAttribute('regular', Mage::helper('enterprise_giftcard')->__('From') . ': ' . Mage::helper('core')->currency($_min, true, false));
         }
     }
 }
开发者ID:cnglobal-sl,项目名称:caterez,代码行数:18,代码来源:Giftcard.php

示例12: _buildRecursive

 /**
  * Recursively build XML configuration tree
  *
  * @param Mage_XmlConnect_Model_Simplexml_Element $section
  * @param array $subTree
  * @return Mage_XmlConnect_Block_Configuration
  */
 protected function _buildRecursive($section, $subTree)
 {
     Mage::helper('xmlconnect')->getDeviceHelper()->checkRequiredConfigFields($subTree);
     foreach ($subTree as $key => $value) {
         if (is_array($value)) {
             if ($key == 'fonts') {
                 $subSection = $section->addChild('fonts');
                 foreach ($value as $label => $val) {
                     if (empty($val['name']) || empty($val['size']) || empty($val['color'])) {
                         continue;
                     }
                     $font = $subSection->addChild('font');
                     $font->addAttribute('label', $label);
                     $font->addAttribute('name', $val['name']);
                     $font->addAttribute('size', $val['size']);
                     $font->addAttribute('color', $val['color']);
                 }
             } elseif ($key == 'pages') {
                 $subSection = $section->addChild('content');
                 foreach ($value as $page) {
                     $this->_buildRecursive($subSection->addChild('page'), $page);
                 }
             } else {
                 $subSection = $section->addChild($key);
                 $this->_buildRecursive($subSection, $value);
             }
         } elseif ($value instanceof Mage_XmlConnect_Model_Tabs) {
             foreach ($value->getRenderTabs() as $tab) {
                 $subSection = $section->addChild('tab');
                 $this->_buildRecursive($subSection, $tab);
             }
         } else {
             $value = (string) $value;
             if ($value != '') {
                 $section->addChild($key, Mage::helper('core')->escapeHtml($value));
             }
         }
     }
     return $this;
 }
开发者ID:cewolf2002,项目名称:magento,代码行数:47,代码来源:Configuration.php

示例13: reviewToXmlObject

 /**
  * Retrieve review data as xml object
  *
  * @param Mage_Review_Model_Review $review
  * @param string $itemNodeName
  * @return Mage_XmlConnect_Model_Simplexml_Element
  */
 public function reviewToXmlObject(Mage_Review_Model_Review $review, $itemNodeName = 'item')
 {
     $rating = 0;
     $item = new Mage_XmlConnect_Model_Simplexml_Element('<' . $itemNodeName . '></' . $itemNodeName . '>');
     if ($review->getId()) {
         $item->addChild('review_id', $review->getId());
         $item->addChild('created_at', $this->formatDate($review->getCreatedAt()));
         $item->addChild('title', $item->xmlentities(strip_tags($review->getTitle())));
         $item->addChild('nickname', $item->xmlentities(strip_tags($review->getNickname())));
         $detail = $item->xmlentities($review->getDetail());
         if ($itemNodeName == 'item') {
             $remainder = '';
             $deviceType = Mage::helper('xmlconnect')->getDeviceType();
             if ($deviceType != Mage_XmlConnect_Helper_Data::DEVICE_TYPE_IPAD) {
                 $detail = Mage::helper('core/string')->truncate($detail, self::REVIEW_DETAIL_TRUNCATE_LEN, '', $remainder, false);
             }
         }
         $item->addChild('detail', $detail);
         $summary = Mage::getModel('rating/rating')->getReviewSummary($review->getId());
         if ($summary->getCount() > 0) {
             $rating = round($summary->getSum() / $summary->getCount() / 10);
         }
         if ($rating) {
             $item->addChild('rating_votes', $rating);
         }
     }
     return $item;
 }
开发者ID:xiaoguizhidao,项目名称:emporiodopara,代码行数:35,代码来源:Review.php

示例14: _buildRecursive

 /**
  * Recursively build XML configuration tree
  *
  * @param Mage_XmlConnect_Model_Simplexml_Element $section
  * @param array $subtree
  * @return Mage_XmlConnect_Model_Simplexml_Element
  */
 protected function _buildRecursive($section, $subtree)
 {
     foreach ($subtree as $key => $value) {
         if (is_array($value)) {
             if ($key == 'fonts') {
                 $subsection = $section->addChild('fonts');
                 foreach ($value as $label => $v) {
                     if (empty($v['name']) || empty($v['size']) || empty($v['color'])) {
                         continue;
                     }
                     $font = $subsection->addChild('font');
                     $font->addAttribute('label', $label);
                     $font->addAttribute('name', $v['name']);
                     $font->addAttribute('size', $v['size']);
                     $font->addAttribute('color', $v['color']);
                 }
             } elseif ($key == 'pages') {
                 $subsection = $section->addChild('content');
                 foreach ($value as $page) {
                     $this->_buildRecursive($subsection->addChild('page'), $page);
                 }
             } else {
                 $subsection = $section->addChild($key);
                 $this->_buildRecursive($subsection, $value);
             }
         } elseif ($value instanceof Mage_XmlConnect_Model_Tabs) {
             foreach ($value->getRenderTabs() as $tab) {
                 $subsection = $section->addChild('tab');
                 $this->_buildRecursive($subsection, $tab);
             }
         } else {
             $value = (string) $value;
             if ($value != '') {
                 $section->addChild($key, Mage::helper('core')->htmlEscape($value));
             }
         }
     }
 }
开发者ID:votanlean,项目名称:Magento-Pruebas,代码行数:45,代码来源:Configuration.php

示例15: getCategoryInfoXmlObject

 /**
  * Produce category info xml object
  *
  * @return Mage_XmlConnect_Model_Simplexml_Element
  */
 public function getCategoryInfoXmlObject()
 {
     $infoXmlObj = new Mage_XmlConnect_Model_Simplexml_Element('<category_info></category_info>');
     $category = $this->getCategory();
     if ($category && is_object($category) && $category->getId()) {
         /**
          * @var string $title
          *
          * Copied data from "getDefaultApplicationDesignTabs()" method in "Mage_XmlConnect_Helper_Data"
          */
         $title = $this->__('Shop');
         if ($category->getParentCategory()->getLevel() > 1) {
             $title = $infoXmlObj->xmlentities(strip_tags($category->getParentCategory()->getName()));
         }
         $infoXmlObj->addChild('parent_title', $title);
         $pId = 0;
         if ($category->getLevel() > 1) {
             $pId = $category->getParentId();
         }
         $infoXmlObj->addChild('parent_id', $pId);
     }
     return $infoXmlObj;
 }
开发者ID:votanlean,项目名称:Magento-Pruebas,代码行数:28,代码来源:Info.php


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