本文整理汇总了PHP中Mage_XmlConnect_Model_Simplexml_Element类的典型用法代码示例。如果您正苦于以下问题:PHP Mage_XmlConnect_Model_Simplexml_Element类的具体用法?PHP Mage_XmlConnect_Model_Simplexml_Element怎么用?PHP Mage_XmlConnect_Model_Simplexml_Element使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Mage_XmlConnect_Model_Simplexml_Element类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addToXmlObjectApi23
/**
* Add order total rendered to XML object. Api version 23
*
* @param $totalsXml Mage_XmlConnect_Model_Simplexml_Element
* @return null
*/
public function addToXmlObjectApi23(Mage_XmlConnect_Model_Simplexml_Element $totalsXml)
{
$balance = $this->getSource()->getCustomerBalanceAmount();
if ($balance) {
$totalsXml->addCustomChild('item', '-' . $this->_formatPrice($balance), array('id' => $this->getTotal()->getCode(), 'label' => Mage::helper('enterprise_giftcardaccount')->__('Store Credit')));
}
}
示例2: _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();
}
示例3: addLastOrdersToXmlObj
/**
* Add last orders info to xml object
*
* @param Mage_XmlConnect_Model_Simplexml_Element $xmlObj
* @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_LastOrders
*/
public function addLastOrdersToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $xmlObj)
{
if (!Mage::helper('core')->isModuleEnabled('Mage_Reports')) {
return $this;
}
/** @var $collection Mage_Reports_Model_Resource_Order_Collection */
$collection = Mage::getResourceModel('reports/order_collection')->addItemCountExpr()->joinCustomerName('customer')->orderByCreatedAt()->setPageSize(self::LAST_ORDER_COUNT_LIMIT);
foreach (Mage::helper('xmlconnect/adminApplication')->getSwitcherList() as $storeId) {
if ($storeId) {
$collection->addAttributeToFilter('store_id', $storeId);
$collection->addRevenueToSelect();
} else {
$collection->addRevenueToSelect(true);
}
$this->setCollection($collection);
$orderList = $this->_prepareColumns()->getCollection()->load();
$valuesXmlObj = $xmlObj->addCustomChild('values', null, array('store_id' => $storeId ? $storeId : Mage_XmlConnect_Helper_AdminApplication::ALL_STORE_VIEWS));
foreach ($orderList as $order) {
$itemXmlObj = $valuesXmlObj->addCustomChild('item');
$itemXmlObj->addCustomChild('customer', $order->getCustomer(), array('label' => $this->__('Customer')));
$itemXmlObj->addCustomChild('items_count', $order->getItemsCount(), array('label' => $this->__('Items')));
$currency_code = Mage::app()->getStore($storeId)->getBaseCurrencyCode();
$itemXmlObj->addCustomChild('currency', Mage::app()->getLocale()->currency($currency_code)->toCurrency($order->getRevenue()), array('label' => $this->__('Grand Total')));
}
$collection->clear();
}
return $this;
}
示例4: _addLocalization
/**
* Add localization data to xml object
*
* @param Mage_XmlConnect_Model_Simplexml_Element $xml
* @return Mage_XmlConnect_Block_Adminhtml_Connect_Config
*/
protected function _addLocalization(Mage_XmlConnect_Model_Simplexml_Element $xml)
{
/** @var $translateHelper Mage_XmlConnect_Helper_Translate */
$translateHelper = Mage::helper('xmlconnect/translate');
$xml->addCustomChild('localization', $this->getUrl('*/*/localization'), array('hash' => sha1(serialize($translateHelper->getLocalizationArray()))));
return $this;
}
示例5: _addOldStandardValue
/**
* Get values using old standard
*
* @deprecated old output standard
* @param Mage_XmlConnect_Model_Simplexml_Element $xmlObj
* @return Mage_XmlConnect_Model_Simplexml_Form_Element_CountryListSelect
*/
protected function _addOldStandardValue(Mage_XmlConnect_Model_Simplexml_Element $xmlObj)
{
$countries = $this->_getCountryOptions();
if (is_array($countries)) {
$valuesXmlObj = $xmlObj->addCustomChild('values');
foreach ($countries as $data) {
$regions = array();
if ($data['value']) {
$regions = $this->_getRegionOptions($data['value']);
}
$relationType = is_array($regions) && !empty($regions) ? 'region_id' : 'region';
$selectedCountry = array();
if ($this->getCountryId() == $data['value']) {
$selectedCountry = array('selected' => 1);
}
$item = $valuesXmlObj->addCustomChild('item', null, array('relation' => $relationType) + $selectedCountry);
$item->addCustomChild('label', (string) $data['label']);
$item->addCustomChild('value', $data['value']);
if ($relationType == 'region_id') {
$regionsXmlObj = $item->addCustomChild('regions');
foreach ($regions as $regionData) {
$selectedRegion = array();
if (!empty($selectedCountry) && $this->getRegionId() == $regionData['value']) {
$selectedRegion = array('selected' => 1);
}
$regionItem = $regionsXmlObj->addCustomChild('region_item', null, $selectedRegion);
$regionItem->addCustomChild('label', (string) $regionData['label']);
$regionItem->addCustomChild('value', (string) $regionData['value']);
}
}
}
}
return $this;
}
示例6: _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();
}
示例7: _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();
}
示例8: 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);
}
示例9: 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;
}
示例10: _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();
}
示例11: addPaymentInfoToXmlObj
/**
* Add CC Save Payment info to order XML object
*
* @param Mage_XmlConnect_Model_Simplexml_Element $orderItemXmlObj
* @return Mage_XmlConnect_Model_Simplexml_Element
*/
public function addPaymentInfoToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $orderItemXmlObj)
{
$orderItemXmlObj->addAttribute('type', $this->getMethod()->getCode());
$orderItemXmlObj->addAttribute('title', $orderItemXmlObj->xmlAttribute($this->getMethod()->getTitle()));
if ($_specificInfo = $this->getSpecificInformation()) {
foreach ($_specificInfo as $label => $value) {
$orderItemXmlObj->addCustomChild('item', implode($this->getValueAsArray($value, true), '\\n'), array('label' => $label));
}
}
}
示例12: _addValue
/**
* Add value to element
*
* @param Mage_XmlConnect_Model_Simplexml_Element $xmlObj
* @return Mage_XmlConnect_Model_Simplexml_Form_Element_Abstract
*/
protected function _addValue(Mage_XmlConnect_Model_Simplexml_Element $xmlObj)
{
$values = $this->getEscapedValue();
if (!empty($values)) {
$valuesXmlObj = $xmlObj->addCustomChild('values');
foreach ($values as $element => $config) {
$valuesXmlObj->addCustomChild('item', null, array('id' => $config['id'], 'title' => $config['title'], 'label' => $config['label'], 'type' => $element, 'value' => $config['value']));
}
}
return $this;
}
示例13: _addOptions
/**
* Add options to select
*
* @param Mage_XmlConnect_Model_Simplexml_Element $xmlObj
* @return Mage_XmlConnect_Model_Simplexml_Form_Element_Select
*/
protected function _addOptions(Mage_XmlConnect_Model_Simplexml_Element $xmlObj)
{
if ($this->getOptions() && is_array($this->getOptions())) {
$valuesXmlObj = $xmlObj->addCustomChild('values');
foreach ($this->getOptions() as $option) {
if (!isset($option['value']) || $option['value'] == '') {
continue;
}
$valuesXmlObj->addCustomChild('item', null, array('label' => $option['label'], 'value' => $option['value']));
}
}
}
示例14: 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));
}
}
}
示例15: addItemToXmlObject
/**
* Add item to XML object
* (get from template: downloadable/sales/order/items/renderer/downloadable.phtml)
*
* @param Mage_XmlConnect_Model_Simplexml_Element $orderItemXmlObj
* @return null
*/
public function addItemToXmlObject(Mage_XmlConnect_Model_Simplexml_Element $orderItemXmlObj)
{
/** @var $item Mage_Sales_Model_Order_Item */
$item = $this->getItem();
/** @var $itemXml Mage_XmlConnect_Model_Simplexml_Element */
$itemXml = $orderItemXmlObj->addCustomChild('item', null, array('product_id' => $item->getProductId()));
$itemXml->addCustomChild('name', $item->getName());
/** @var $weeeHelper Mage_Weee_Helper_Data */
$weeeHelper = $this->helper('weee');
/** @var $taxHelper Mage_Tax_Helper_Data */
$taxHelper = $this->helper('tax');
Mage::helper('xmlconnect/customer_order')->addItemOptionsToXml($this, $itemXml);
$addtInfoBlock = $this->getProductAdditionalInformationBlock();
if ($addtInfoBlock) {
// TODO: find how to set additional info block
// $addtInfoBlock->setItem($item)->toHtml();
}
$links = $this->getLinks();
if ($links) {
$linksXml = $itemXml->addCustomChild('links', null, array('label' => $this->getLinksTitle()));
foreach ($links->getPurchasedItems() as $link) {
$linksXml->addCustomChild('link', $link->getLinkTitle());
}
}
$itemXml->addCustomChild('entity_type', $item->getProductType());
$itemXml->addCustomChild('description', $item->getDescription());
$itemXml->addCustomChild('sku', Mage::helper('core/string')->splitInjection($this->getSku()));
/** @var $priceXml Mage_XmlConnect_Model_Simplexml_Element */
$priceXml = $itemXml->addChild('price');
// Quantity: Ordered, Shipped, Cancelled, Refunded
Mage::helper('xmlconnect/customer_order')->addQuantityToXml($this, $itemXml->addChild('qty'), $item);
/** @var $subtotalXml Mage_XmlConnect_Model_Simplexml_Element */
$subtotalXml = $itemXml->addChild('subtotal');
$this->setWeeeTaxAppliedAmount($item->getWeeeTaxAppliedAmount());
$this->setWeeeTaxDisposition($item->getWeeeTaxDisposition());
$typeOfDisplay1 = $weeeHelper->typeOfDisplay($item, 1, 'sales') && $this->getWeeeTaxAppliedAmount();
$typeOfDisplay2 = $weeeHelper->typeOfDisplay($item, 2, 'sales') && $this->getWeeeTaxAppliedAmount();
$typeOfDisplay4 = $weeeHelper->typeOfDisplay($item, 4, 'sales') && $this->getWeeeTaxAppliedAmount();
$typeOfDisplay014 = $weeeHelper->typeOfDisplay($item, array(0, 1, 4), 'sales') && $this->getWeeeTaxAppliedAmount();
$this->setTypesOfDisplay(array(Mage_XmlConnect_Helper_Customer_Order::PRICE_DISPLAY_TYPE_1 => $typeOfDisplay1, Mage_XmlConnect_Helper_Customer_Order::PRICE_DISPLAY_TYPE_2 => $typeOfDisplay2, Mage_XmlConnect_Helper_Customer_Order::PRICE_DISPLAY_TYPE_4 => $typeOfDisplay4, Mage_XmlConnect_Helper_Customer_Order::PRICE_DISPLAY_TYPE_14 => $typeOfDisplay014));
$this->setWeeeTaxes($weeeHelper->getApplied($item));
// Price & subtotal - excluding tax
if ($taxHelper->displaySalesBothPrices() || $taxHelper->displaySalesPriceExclTax()) {
Mage::helper('xmlconnect/customer_order')->addPriceAndSubtotalToXml($this, $item, $priceXml, $subtotalXml);
}
// Price & subtotal - including tax
if ($taxHelper->displaySalesBothPrices() || $taxHelper->displaySalesPriceInclTax()) {
Mage::helper('xmlconnect/customer_order')->addPriceAndSubtotalToXml($this, $item, $priceXml, $subtotalXml, true);
}
}