本文整理汇总了PHP中Mage_XmlConnect_Model_Simplexml_Element::asNiceXml方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_XmlConnect_Model_Simplexml_Element::asNiceXml方法的具体用法?PHP Mage_XmlConnect_Model_Simplexml_Element::asNiceXml怎么用?PHP Mage_XmlConnect_Model_Simplexml_Element::asNiceXml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_XmlConnect_Model_Simplexml_Element
的用法示例。
在下文中一共展示了Mage_XmlConnect_Model_Simplexml_Element::asNiceXml方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _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();
}
示例2: _toHtml
/**
* Render order review xml
*
* @return string
*/
protected function _toHtml()
{
$orderXmlObj = new Mage_XmlConnect_Model_Simplexml_Element('<order></order>');
/**
* Order items
*/
$products = $this->getChildHtml('order_products');
if ($products) {
$productsXmlObj = new Mage_XmlConnect_Model_Simplexml_Element($products);
$orderXmlObj->appendChild($productsXmlObj);
}
/**
* Totals
*/
$totalsXml = $this->getChildHtml('totals');
if ($totalsXml) {
$totalsXmlObj = new Mage_XmlConnect_Model_Simplexml_Element($totalsXml);
$orderXmlObj->appendChild($totalsXmlObj);
}
/**
* Agreements
*/
$agreements = $this->getChildHtml('agreements');
if ($agreements) {
$agreementsXmlObj = new Mage_XmlConnect_Model_Simplexml_Element($agreements);
$orderXmlObj->appendChild($agreementsXmlObj);
}
return $orderXmlObj->asNiceXml();
}
示例3: _toHtml
/**
* Render customer address list xml
*
* @return string
*/
protected function _toHtml()
{
$addressXmlObj = new Mage_XmlConnect_Model_Simplexml_Element('<address></address>');
$customer = Mage::getSingleton('customer/session')->getCustomer();
$_billingAddssesId = $customer->getDefaultBilling();
$_shippingAddssesId = $customer->getDefaultShipping();
$billingAddress = $customer->getAddressById($_billingAddssesId);
$shippingAddress = $customer->getAddressById($_shippingAddssesId);
if ($billingAddress && $billingAddress->getId()) {
$item = $addressXmlObj->addChild('item');
$item->addAttribute('label', $this->__('Default Billing Address'));
$item->addAttribute('default_billing', 1);
$this->prepareAddressData($billingAddress, $item);
}
if ($shippingAddress && $shippingAddress->getId()) {
$item = $addressXmlObj->addChild('item');
$item->addAttribute('label', $this->__('Default Shipping Address'));
$item->addAttribute('default_shipping', 1);
$this->prepareAddressData($shippingAddress, $item);
}
$_additionalAddresses = $customer->getAdditionalAddresses();
if ($_additionalAddresses) {
foreach ($_additionalAddresses as $_address) {
$item = $addressXmlObj->addChild('item');
$item->addAttribute('label', $this->__('Additional Address'));
$item->addAttribute('additional', 1);
$this->prepareAddressData($_address, $item);
}
}
return $addressXmlObj->asNiceXml();
}
示例4: _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();
}
示例5: _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();
}
示例6: getProductOptionsXml
/**
* Generate bundle product options xml
*
* @param Mage_Catalog_Model_Product $product
* @param bool $isObject
* @return string | Mage_XmlConnect_Model_Simplexml_Element
*/
public function getProductOptionsXml(Mage_Catalog_Model_Product $product, $isObject = false)
{
$xmlModel = new Mage_XmlConnect_Model_Simplexml_Element('<product></product>');
$optionsNode = $xmlModel->addChild('options');
if (!$product->getId()) {
return $isObject ? $xmlModel : $xmlModel->asNiceXml();
}
$xmlModel->addAttribute('id', $product->getId());
if (!$product->isSaleable()) {
return $isObject ? $xmlModel : $xmlModel->asNiceXml();
}
/**
* Grouped (associated) products
*/
$_associatedProducts = $product->getTypeInstance(true)->getAssociatedProducts($product);
if (!sizeof($_associatedProducts)) {
return $isObject ? $xmlModel : $xmlModel->asNiceXml();
}
foreach ($_associatedProducts as $_item) {
if (!$_item->isSaleable()) {
continue;
}
$optionNode = $optionsNode->addChild('option');
$optionNode->addAttribute('code', 'super_group[' . $_item->getId() . ']');
$optionNode->addAttribute('type', 'product');
$optionNode->addAttribute('label', $xmlModel->xmlentities(strip_tags($_item->getName())));
$optionNode->addAttribute('is_qty_editable', 1);
$optionNode->addAttribute('qty', $_item->getQty() * 1);
/**
* Process product price
*/
if ($_item->getPrice() != $_item->getFinalPrice()) {
$productPrice = $_item->getFinalPrice();
} else {
$productPrice = $_item->getPrice();
}
$productPrice = Mage::helper('xmlconnect')->formatPriceForXml($productPrice);
if ($productPrice != 0.0) {
$optionNode->addAttribute('price', Mage::helper('xmlconnect')->formatPriceForXml(Mage::helper('core')->currency($productPrice, false, false)));
$optionNode->addAttribute('formated_price', $this->_formatPriceString($productPrice, $product));
}
}
return $isObject ? $xmlModel : $xmlModel->asNiceXml();
}
示例7: _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();
}
示例8: _toHtml
/**
* Render cart totals xml
*
* @return string
*/
protected function _toHtml()
{
$quote = $this->getQuote();
$totalsXmlObj = new Mage_XmlConnect_Model_Simplexml_Element('<cart_totals></cart_totals>');
list($items, $totals) = Mage::helper('paypal')->prepareLineItems($quote);
if (Mage::helper('paypal')->areCartLineItemsValid($items, $totals, $quote->getBaseGrandTotal())) {
foreach ($totals as $code => $amount) {
$currencyAmount = $this->helper('core')->currency($amount, false, false);
$totalsXmlObj->addChild($code, Mage::helper('xmlconnect')->formatPriceForXml($currencyAmount));
}
} else {
Mage::throwException($this->__('Cart line items are not eligible for exporting to PayPal API'));
}
return $totalsXmlObj->asNiceXml();
}
示例9: _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();
}
示例10: _toHtml
/**
* Render agreements xml
*
* @return string
*/
protected function _toHtml()
{
$agreementsXmlObj = new Mage_XmlConnect_Model_Simplexml_Element('<agreements></agreements>');
if ($this->getAgreements()) {
foreach ($this->getAgreements() as $agreement) {
$itemXmlObj = $agreementsXmlObj->addChild('item');
$content = $agreementsXmlObj->xmlentities($agreement->getContent());
if (!$agreement->getIsHtml()) {
$content = nl2br(strip_tags($content));
}
$itemXmlObj->addChild('label', $agreementsXmlObj->xmlentities(strip_tags($agreement->getCheckboxText())));
$itemXmlObj->addChild('content', $content);
$itemXmlObj->addChild('code', 'agreement[' . $agreement->getId() . ']');
$itemXmlObj->addChild('agreement_id', $agreement->getId());
}
}
return $agreementsXmlObj->asNiceXml();
}
示例11: _toHtml
/**
* Search suggestions xml renderer
*
* @return string
*/
protected function _toHtml()
{
$suggestXmlObj = new Mage_XmlConnect_Model_Simplexml_Element('<suggestions></suggestions>');
if (!$this->getRequest()->getParam('q', false)) {
return $suggestXmlObj->asNiceXml();
}
$handler = Mage::getSingleton('factfinder_suggest/handler_suggest', array($this->getRequest()->getParam('q')));
$suggestData = $handler->getSuggestionsAsArray();
if (!($count = count($suggestData))) {
return $suggestXmlObj->asNiceXml();
}
$items = '';
foreach ($suggestData as $index => $item) {
$items .= $suggestXmlObj->xmlentities(strip_tags($item['query'])) . self::SUGGEST_ITEM_SEPARATOR . (int) $item['hitCount'] . self::SUGGEST_ITEM_SEPARATOR;
}
$suggestXmlObj = new Mage_XmlConnect_Model_Simplexml_Element('<suggestions>' . $items . '</suggestions>');
return $suggestXmlObj->asNiceXml();
}
示例12: _toHtml
/**
* Render billing shipping xml
*
* @return string
*/
protected function _toHtml()
{
$shippingXmlObj = new Mage_XmlConnect_Model_Simplexml_Element('<shipping></shipping>');
$addressId = $this->getAddress()->getId();
$address = $this->getCustomer()->getPrimaryShippingAddress();
if ($address) {
$addressId = $address->getId();
}
foreach ($this->getCustomer()->getAddresses() as $address) {
$item = $shippingXmlObj->addChild('item');
if ($addressId == $address->getId()) {
$item->addAttribute('selected', 1);
}
$this->getChild('address_list')->prepareAddressData($address, $item);
$item->addChild('address_line', $shippingXmlObj->xmlentities($address->format('oneline')));
}
return $shippingXmlObj->asNiceXml();
}
示例13: _toHtml
/**
* Search suggestions xml renderer
*
* @return string
*/
protected function _toHtml()
{
$suggestXmlObj = new Mage_XmlConnect_Model_Simplexml_Element('<suggestions></suggestions>');
if (!$this->getRequest()->getParam('q', false)) {
return $suggestXmlObj->asNiceXml();
}
$suggestData = $this->getSuggestData();
if (!($count = count($suggestData))) {
return $suggestXmlObj->asNiceXml();
}
$items = '';
foreach ($suggestData as $index => $item) {
$items .= $suggestXmlObj->xmlentities(strip_tags($item['title'])) . self::SUGGEST_ITEM_SEPARATOR . (int) $item['num_of_results'] . self::SUGGEST_ITEM_SEPARATOR;
// $itemXmlObj = $suggestXmlObj->addChild('item');
// $itemXmlObj->addChild('title', $suggestXmlObj->xmlentities(strip_tags($item['title'])));
// $itemXmlObj->addChild('count', (int)$item['num_of_results']);
}
$suggestXmlObj = new Mage_XmlConnect_Model_Simplexml_Element('<suggestions>' . $items . '</suggestions>');
return $suggestXmlObj->asNiceXml();
}
示例14: _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();
}
示例15: _toHtml
/**
* Render filters list xml
*
* @return string
*/
protected function _toHtml()
{
$categoryId = $this->getRequest()->getParam('category_id', null);
$categoryXmlObj = new Mage_XmlConnect_Model_Simplexml_Element('<category></category>');
$filtersCollection = Mage::getResourceModel('xmlconnect/filter_collection')->setCategoryId($categoryId);
$filtersXmlObj = $categoryXmlObj->addChild('filters');
foreach ($filtersCollection->getItems() as $item) {
if (!sizeof($item->getValues())) {
continue;
}
$itemXmlObj = $filtersXmlObj->addChild('item');
$itemXmlObj->addChild('name', $categoryXmlObj->xmlentities(strip_tags($item->getName())));
$itemXmlObj->addChild('code', $categoryXmlObj->xmlentities($item->getCode()));
$valuesXmlObj = $itemXmlObj->addChild('values');
foreach ($item->getValues() as $value) {
$valueXmlObj = $valuesXmlObj->addChild('value');
$valueXmlObj->addChild('id', $categoryXmlObj->xmlentities($value->getValueString()));
$valueXmlObj->addChild('label', $categoryXmlObj->xmlentities(strip_tags($value->getLabel())));
$valueXmlObj->addChild('count', (int) $value->getProductsCount());
}
}
$categoryXmlObj->appendChild($this->getProductSortFeildsXmlObject());
return $categoryXmlObj->asNiceXml();
}