本文整理汇总了PHP中Mage_XmlConnect_Model_Simplexml_Element::appendChild方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_XmlConnect_Model_Simplexml_Element::appendChild方法的具体用法?PHP Mage_XmlConnect_Model_Simplexml_Element::appendChild怎么用?PHP Mage_XmlConnect_Model_Simplexml_Element::appendChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_XmlConnect_Model_Simplexml_Element
的用法示例。
在下文中一共展示了Mage_XmlConnect_Model_Simplexml_Element::appendChild方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _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();
}
示例2: _toHtml
/**
* Render block HTML
*
* @return string
*/
protected function _toHtml()
{
$categoryXmlObj = new Mage_XmlConnect_Model_Simplexml_Element('<category></category>');
$categoryId = $this->getRequest()->getParam('id', null);
if ($categoryId === null) {
$categoryId = Mage::app()->getStore()->getRootCategoryId();
}
$productsXmlObj = $productListBlock = false;
$categoryModel = Mage::getModel('catalog/category')->load($categoryId);
if ($categoryModel->getId()) {
$hasMoreProductItems = 0;
$productListBlock = $this->getChild('product_list');
if ($productListBlock && $categoryModel->getLevel() > 1) {
$layer = Mage::getSingleton('catalog/layer');
$productsXmlObj = $productListBlock->setCategory($categoryModel)->setLayer($layer)->getProductsXmlObject();
$hasMoreProductItems = (int) $productListBlock->getHasProductItems();
}
$infoBlock = $this->getChild('category_info');
if ($infoBlock) {
$categoryInfoXmlObj = $infoBlock->setCategory($categoryModel)->getCategoryInfoXmlObject();
$categoryInfoXmlObj->addChild('has_more_items', $hasMoreProductItems);
$categoryXmlObj->appendChild($categoryInfoXmlObj);
}
}
/** @var $categoryCollection Mage_XmlConnect_Model_Mysql4_Category_Collection */
$categoryCollection = Mage::getResourceModel('xmlconnect/category_collection');
$categoryCollection->setStoreId(Mage::app()->getStore()->getId())->setOrder('position', 'ASC')->addParentIdFilter($categoryId);
// subcategories are exists
if (sizeof($categoryCollection)) {
$itemsXmlObj = $categoryXmlObj->addChild('items');
foreach ($categoryCollection->getItems() as $item) {
$itemXmlObj = $itemsXmlObj->addChild('item');
$itemXmlObj->addChild('label', $categoryXmlObj->xmlentities(strip_tags($item->getName())));
$itemXmlObj->addChild('entity_id', $item->getEntityId());
$itemXmlObj->addChild('content_type', $item->hasChildren() ? 'categories' : 'products');
if (!is_null($categoryId)) {
$itemXmlObj->addChild('parent_id', $item->getParentId());
}
$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));
}
}
if ($productListBlock && $productsXmlObj) {
$categoryXmlObj->appendChild($productsXmlObj);
}
return $categoryXmlObj->asNiceXml();
}
示例3: 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;
}
示例4: _addProductXmlObj
/**
* Add related products info to xml object
*
* @param Mage_XmlConnect_Model_Simplexml_Element $relatedXmlObj
* @param array $collection
* @return Mage_XmlConnect_Model_Simplexml_Element
*/
protected function _addProductXmlObj(Mage_XmlConnect_Model_Simplexml_Element $relatedXmlObj, $collection)
{
foreach ($collection as $product) {
$productXmlObj = $this->productToXmlObject($product);
if (!$productXmlObj) {
continue;
}
if ($this->getParentBlock()->getChild('product_price')) {
$this->getParentBlock()->getChild('product_price')->setProduct($product)->setProductXmlObj($productXmlObj)->collectProductPrices();
}
$relatedXmlObj->appendChild($productXmlObj);
}
return $relatedXmlObj;
}
示例5: getReviewsXmlObject
/**
* Produce reviews list xml object
*
* @return Mage_XmlConnect_Model_Simplexml_Element
*/
public function getReviewsXmlObject()
{
$reviewsXmlObj = new Mage_XmlConnect_Model_Simplexml_Element('<reviews></reviews>');
$collection = $this->_getReviewCollection();
if (!$collection) {
return $reviewsXmlObj;
}
foreach ($collection->getItems() as $review) {
$reviewXmlObj = $this->reviewToXmlObject($review);
if ($reviewXmlObj) {
$reviewsXmlObj->appendChild($reviewXmlObj);
}
}
return $reviewsXmlObj;
}
示例6: getProductsXmlObject
/**
* Produce products list xml object
*
* @return Mage_XmlConnect_Model_Simplexml_Element
*/
public function getProductsXmlObject()
{
$productsXmlObj = new Mage_XmlConnect_Model_Simplexml_Element('<products></products>');
$collection = $this->_getProductCollection();
if (!$collection) {
return false;
}
foreach ($collection->getItems() as $product) {
$productXmlObj = $this->productToXmlObject($product);
if ($productXmlObj) {
$productsXmlObj->appendChild($productXmlObj);
}
}
return $productsXmlObj;
}
示例7: addSwitcherToXmlObj
/**
* Add sales info to xml object
*
* @param Mage_XmlConnect_Model_Simplexml_Element $xmlObj
* @return Mage_XmlConnect_Block_Adminhtml_Connect_StoreSwitcher
*/
public function addSwitcherToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $xmlObj)
{
$websites = $this->getWebsites();
if ($websites) {
$this->setUseConfirm(false);
/** @var $storeSwitcherField Mage_XmlConnect_Model_Simplexml_Form_Element_Custom */
$storeSwitcherField = Mage::getModel('xmlconnect/simplexml_form_element_custom', array('label' => $this->__('Choose Store View')));
$storeSwitcherField->setId('store_id');
$storeSwitcherXmlObj = $storeSwitcherField->toXmlObject();
$this->_createStoreItemList($websites, $storeSwitcherXmlObj);
if (!$storeSwitcherXmlObj->getAttribute('value')) {
$storeSwitcherXmlObj->addAttribute('value', Mage_XmlConnect_Helper_AdminApplication::ALL_STORE_VIEWS);
}
$xmlObj->appendChild($storeSwitcherXmlObj);
}
return $this;
}
示例8: _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();
}
示例9: addSalesInfoToXmlObj
/**
* Add sales info to xml object
*
* @param Mage_XmlConnect_Model_Simplexml_Element $xmlObj
* @return Mage_XmlConnect_Block_Adminhtml_Connect_SalesInfo
*/
public function addSalesInfoToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $xmlObj)
{
if (count($this->getTotals()) > 0) {
/** @var $salesInfoField Mage_XmlConnect_Model_Simplexml_Form_Element_Custom */
$salesInfoField = Mage::getModel('xmlconnect/simplexml_form_element_custom', array('label' => ''));
$salesInfoField->setId('sales_info');
$salesInfoXmlObj = $salesInfoField->toXmlObject();
$storeId = null;
foreach ($this->getTotals() as $total) {
if (null === $storeId || $storeId !== $total['store_id']) {
$storeId = $total['store_id'];
$valuesXmlObj = $salesInfoXmlObj->addCustomChild('values', null, array('store_id' => $storeId));
}
$valuesXmlObj->addCustomChild('item', strip_tags($total['value']), array('label' => $total['label']));
}
$xmlObj->appendChild($salesInfoXmlObj);
}
return $this;
}
示例10: getRelatedProductsXmlObj
/**
* Retrieve related products xml object based on current product
*
* @return Mage_XmlConnect_Model_Simplexml_Element
* @see $this->getProduct()
*/
public function getRelatedProductsXmlObj()
{
$relatedXmlObj = new Mage_XmlConnect_Model_Simplexml_Element('<related_products></related_products>');
if ($this->getParentBlock()->getProduct()->getId() > 0) {
$collection = $this->_getProductCollection();
if (!$collection) {
return $relatedXmlObj;
}
foreach ($collection->getItems() as $product) {
$productXmlObj = $this->productToXmlObject($product);
if ($productXmlObj) {
if ($this->getParentBlock()->getChild('product_price')) {
$this->getParentBlock()->getChild('product_price')->setProduct($product)->setProductXmlObj($productXmlObj)->collectProductPrices();
}
$relatedXmlObj->appendChild($productXmlObj);
}
}
}
return $relatedXmlObj;
}
示例11: _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();
}
示例12: _addDataSelector
/**
* Add data select field to xml object
*
* @param Mage_XmlConnect_Model_Simplexml_Element $xmlObj
* @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_GraphInfo
*/
protected function _addDataSelector(Mage_XmlConnect_Model_Simplexml_Element $xmlObj)
{
/** @var $rangeXmlObj Mage_XmlConnect_Model_Simplexml_Form_Element_Select */
$rangeXmlObj = Mage::getModel('xmlconnect/simplexml_form_element_select', array('label' => $this->__('Select Chart'), 'value' => 'orders', 'options' => array(array('label' => $this->__('Orders'), 'value' => 'orders'), array('label' => $this->__('Amounts'), 'value' => 'amounts'))));
$rangeXmlObj->setId('data_details_id');
$xmlObj->appendChild($rangeXmlObj->toXmlObject());
return $this;
}
示例13: addAfterXmlElementToObj
/**
* Add after element xml to object
*
* @param Mage_XmlConnect_Model_Simplexml_Element $xmlObj
* @return Mage_XmlConnect_Model_Simplexml_Form_Abstract
*/
public function addAfterXmlElementToObj(Mage_XmlConnect_Model_Simplexml_Element $xmlObj)
{
if ($this->_checkXmlInstance($this->getAfterElementXml())) {
$xmlObj->appendChild($this->getAfterElementXml());
} elseif (is_array($this->getAfterElementXml())) {
foreach ($this->getAfterElementXml() as $afterElement) {
if (!$this->_checkXmlInstance($afterElement)) {
continue;
}
$xmlObj->appendChild($afterElement);
}
}
return $this;
}
示例14: _toHtml
/**
* Search results xml renderer
* XML also contains filters that can be apply (accorfingly already applyed filters and search query)
* and sort fields
*
* @return string
*/
protected function _toHtml()
{
$searchXmlObject = new Mage_XmlConnect_Model_Simplexml_Element('<search></search>');
$filtersXmlObject = new Mage_XmlConnect_Model_Simplexml_Element('<filters></filters>');
$helper = Mage::helper('catalogsearch');
if (method_exists($helper, 'getEngine')) {
$engine = Mage::helper('catalogsearch')->getEngine();
$isLayeredNavigationAllowed = $engine instanceof Varien_Object ? $engine->isLeyeredNavigationAllowed() : true;
} else {
$isLayeredNavigationAllowed = true;
}
$request = $this->getRequest();
$requestParams = $request->getParams();
$hasMoreProductItems = 0;
/**
* Products
*/
$productListBlock = $this->getChild('product_list');
if ($productListBlock) {
$layer = Mage::getSingleton('catalogsearch/layer');
$productsXmlObj = $productListBlock->setLayer($layer)->setNeedBlockApplyingFilters(!$isLayeredNavigationAllowed)->getProductsXmlObject();
$searchXmlObject->appendChild($productsXmlObj);
$hasMoreProductItems = (int) $productListBlock->getHasProductItems();
}
$searchXmlObject->addAttribute('has_more_items', $hasMoreProductItems);
/**
* Filters
*/
$showFiltersAndOrders = (bool) count($productsXmlObj);
$reguest = $this->getRequest();
foreach ($reguest->getParams() as $key => $value) {
if (0 === strpos($key, parent::REQUEST_SORT_ORDER_PARAM_REFIX) || 0 === strpos($key, parent::REQUEST_FILTER_PARAM_REFIX)) {
$showFiltersAndOrders = false;
break;
}
}
if ($isLayeredNavigationAllowed && $productListBlock && $showFiltersAndOrders) {
$filters = $productListBlock->getCollectedFilters();
/**
* Render filters xml
*/
foreach ($filters as $filter) {
if (!$this->_isFilterItemsHasValues($filter)) {
continue;
}
$item = $filtersXmlObject->addChild('item');
$item->addChild('name', $searchXmlObject->xmlentities($filter->getName()));
$item->addChild('code', $filter->getRequestVar());
$values = $item->addChild('values');
foreach ($filter->getItems() as $valueItem) {
$count = (int) $valueItem->getCount();
if (!$count) {
continue;
}
$value = $values->addChild('value');
$value->addChild('id', $valueItem->getValueString());
$value->addChild('label', $searchXmlObject->xmlentities(strip_tags($valueItem->getLabel())));
$value->addChild('count', $count);
}
}
$searchXmlObject->appendChild($filtersXmlObject);
}
/**
* Sort fields
*/
if ($showFiltersAndOrders) {
$searchXmlObject->appendChild($this->getProductSortFeildsXmlObject());
}
return $searchXmlObject->asNiceXml();
}
示例15: _toHtml
//.........这里部分代码省略.........
$formatedPriceXmlObj->addAttribute('excluding_tax', $formatedExclPrice);
$formatedPriceXmlObj->addAttribute('including_tax', $formatedInclPrice);
} else {
if ($this->helper('tax')->displayCartPriceExclTax()) {
$priceXmlObj->addAttribute('regular', $exclPrice);
$formatedPriceXmlObj->addAttribute('regular', $formatedExclPrice);
}
if ($this->helper('tax')->displayCartPriceInclTax()) {
$priceXmlObj->addAttribute('regular', $inclPrice);
$formatedPriceXmlObj->addAttribute('regular', $formatedInclPrice);
}
}
/**
* Subtotal
*/
$exclPrice = $inclPrice = 0.0;
if ($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()) {
if (Mage::helper('weee')->typeOfDisplay($item, array(0, 1, 4), 'sales') && $item->getWeeeTaxAppliedAmount()) {
$exclPrice = $item->getRowTotal() + $item->getWeeeTaxAppliedRowAmount() + $item->getWeeeTaxRowDisposition();
} else {
$exclPrice = $item->getRowTotal();
}
}
if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()) {
$_incl = $this->helper('checkout')->getSubtotalInclTax($item);
if (Mage::helper('weee')->typeOfDisplay($item, array(0, 1, 4), 'sales') && $item->getWeeeTaxAppliedAmount()) {
$inclPrice = $_incl + $item->getWeeeTaxAppliedRowAmount();
} else {
$inclPrice = $_incl - $item->getWeeeTaxRowDisposition();
}
}
$exclPrice = Mage::helper('xmlconnect')->formatPriceForXml($exclPrice);
$formatedExclPrice = $quote->getStore()->formatPrice($exclPrice, false);
$inclPrice = Mage::helper('xmlconnect')->formatPriceForXml($inclPrice);
$formatedInclPrice = $quote->getStore()->formatPrice($inclPrice, false);
$subtotalPriceXmlObj = $itemXml->addChild('subtotal');
$subtotalFormatedPriceXmlObj = $itemXml->addChild('formated_subtotal');
if ($this->helper('tax')->displayCartBothPrices()) {
$subtotalPriceXmlObj->addAttribute('excluding_tax', $exclPrice);
$subtotalPriceXmlObj->addAttribute('including_tax', $inclPrice);
$subtotalFormatedPriceXmlObj->addAttribute('excluding_tax', $formatedExclPrice);
$subtotalFormatedPriceXmlObj->addAttribute('including_tax', $formatedInclPrice);
} else {
if ($this->helper('tax')->displayCartPriceExclTax()) {
$subtotalPriceXmlObj->addAttribute('regular', $exclPrice);
$subtotalFormatedPriceXmlObj->addAttribute('regular', $formatedExclPrice);
}
if ($this->helper('tax')->displayCartPriceInclTax()) {
$subtotalPriceXmlObj->addAttribute('regular', $inclPrice);
$subtotalFormatedPriceXmlObj->addAttribute('regular', $formatedInclPrice);
}
}
/**
* Options list
*/
if ($_options = $renderer->getOptionList()) {
$itemOptionsXml = $itemXml->addChild('options');
foreach ($_options as $_option) {
$_formatedOptionValue = $renderer->getFormatedOptionValue($_option);
$optionXml = $itemOptionsXml->addChild('option');
$optionXml->addAttribute('label', $xmlObject->xmlentities(strip_tags($_option['label'])));
$optionXml->addAttribute('text', $xmlObject->xmlentities(strip_tags($_formatedOptionValue['value'])));
// if (isset($_formatedOptionValue['full_view'])) {
// $label = strip_tags($_option['label']);
// $value = strip_tags($_formatedOptionValue['full_view']);
// }
}
}
/**
* Item messages
*/
if ($messages = $renderer->getMessages()) {
$itemMessagesXml = $itemXml->addChild('messages');
foreach ($messages as $message) {
$messageXml = $itemMessagesXml->addChild('option');
$messageXml->addChild('type', $message['type']);
$messageXml->addChild('text', $xmlObject->xmlentities(strip_tags($message['text'])));
}
}
}
/**
* Cart messages
*/
if ($cartMessages) {
$messagesXml = $xmlObject->addChild('messages');
foreach ($cartMessages as $status => $messages) {
foreach ($messages as $message) {
$messageXml = $messagesXml->addChild('message');
$messageXml->addChild('status', $status);
$messageXml->addChild('text', strip_tags($message));
}
}
}
/**
* Cross Sell Products
*/
$crossSellXmlObj = new Mage_XmlConnect_Model_Simplexml_Element($this->getChildHtml('crosssell'));
$xmlObject->appendChild($crossSellXmlObj);
return $xmlObject->asNiceXml();
}