/**
  * 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')));
     }
 }
Beispiel #2
0
 /**
  * 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();
 }
 /**
  * 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;
 }
Beispiel #4
0
 /**
  * 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;
 }
 /**
  * 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;
 }
Beispiel #6
0
 /**
  * Add order total rendered to XML object
  *
  * @param $totalsXml Mage_XmlConnect_Model_Simplexml_Element
  * @return null
  */
 public function addToXmlObject(Mage_XmlConnect_Model_Simplexml_Element $totalsXml)
 {
     $balance = $this->getSource()->getCustomerBalanceTotalRefunded();
     if ($balance) {
         $totalsXml->addCustomChild($this->getTotal()->getCode(), $this->_formatPrice($balance), array('label' => Mage::helper('enterprise_giftcardaccount')->__('Refunded to Store Credit')));
     }
 }
 /**
  * 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();
 }
Beispiel #8
0
 /**
  * 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();
 }
Beispiel #9
0
    /**
     * 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);
    }
 /**
  * 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;
 }
Beispiel #11
0
 /**
  * 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();
 }
 /**
  * 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));
         }
     }
 }
Beispiel #13
0
 /**
  * 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;
 }
Beispiel #14
0
 /**
  * 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']));
         }
     }
 }
Beispiel #15
0
 /**
  * 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));
         }
     }
 }
Beispiel #16
0
 /**
  * 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);
     }
 }
Beispiel #17
0
 /**
  * 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;
 }
 /**
  * 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();
 }
 /**
  * Add additional information (attributes) to current product xml object
  *
  * @param Mage_Catalog_Model_Product $product
  * @param Mage_XmlConnect_Model_Simplexml_Element $productXmlObject
  *  
  */
 public function addAdditionalData(Mage_Catalog_Model_Product $product, Mage_XmlConnect_Model_Simplexml_Element $productXmlObject)
 {
     if ($product && $productXmlObject && $product->getId()) {
         $this->_product = $product;
         $additionalData = $this->getAdditionalData();
         if (!empty($additionalData)) {
             $attributesXmlObj = $productXmlObject->addChild('additional_attributes');
             foreach ($additionalData as $data) {
                 $_attrXmlObject = $attributesXmlObj->addChild('item');
                 $_attrXmlObject->addChild('label', $this->htmlEscape($data['label']));
                 $_attrXmlObject->addChild('value', Mage::helper('catalog/output')->productAttribute($product, $data['value'], $data['code']));
             }
         }
     }
 }
Beispiel #20
0
 /**
  * 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)
 {
     $cards = $this->getGiftCards();
     if ($cards) {
         foreach ($cards as $card) {
             $label = Mage::helper('enterprise_giftcardaccount')->__('Gift Card (%s)', $card->getCode());
             $totalsXml->addCustomChild('item', '-' . $this->_formatPrice($card->getAmount()), array('id' => $this->getTotal()->getCode(), 'label' => $label));
         }
     } else {
         $cardsAmount = $this->getSource()->getGiftCardsAmount();
         if ($cardsAmount > 0) {
             $totalsXml->addCustomChild($this->getTotal()->getCode(), '-' . $this->_formatPrice($cardsAmount), array('label' => Mage::helper('enterprise_giftcardaccount')->__('Gift Card')));
         }
     }
 }
Beispiel #21
0
 /**
  * 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();
 }
Beispiel #22
0
 /**
  * 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;
 }
Beispiel #23
0
 /**
  * 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;
 }
 /**
  * Add Authorizenet 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());
     if (!$this->getHideTitle()) {
         $orderItemXmlObj->addAttribute('title', $orderItemXmlObj->xmlAttribute($this->getMethod()->getTitle()));
     }
     $cards = $this->getCards();
     $showCount = count($cards) > 1;
     foreach ($cards as $key => $card) {
         $creditCard = $orderItemXmlObj->addCustomChild('item', null, array('label' => $showCount ? $this->__('Credit Card %s', $key + 1) : $this->__('Credit Card')));
         foreach ($card as $label => $value) {
             $creditCard->addCustomChild('item', implode($this->getValueAsArray($value, true), '\\n'), array('label' => $label));
         }
     }
 }
Beispiel #25
0
 /**
  * Collect product prices to specified item xml object
  *
  * @param Mage_Catalog_Model_Product $product
  * @param Mage_XmlConnect_Model_Simplexml_Element $item
  * @return null
  */
 public function collectProductPrices(Mage_Catalog_Model_Product $product, Mage_XmlConnect_Model_Simplexml_Element $item)
 {
     $this->setProduct($product);
     if ($product->getCanShowPrice() !== false) {
         $priceListXmlObj = $item->addCustomChild('price_list');
         $min = $this->getMinAmount();
         $max = $this->getMaxAmount();
         if ($min && $max && $min == $max) {
             $pricesXmlObj = $priceListXmlObj->addCustomChild('prices', null, array('id' => 'price'));
             $pricesXmlObj->addCustomChild('price', $min, array('id' => 'regular', 'label' => $this->__('Regular'), 'formatted_value' => Mage::helper('core')->currency($min, true, false)));
         } elseif ($min && $min != 0) {
             $pricesXmlObj = $priceListXmlObj->addCustomChild('prices', null, array('id' => 'price'));
             $pricesXmlObj->addCustomChild('price', $min, array('id' => 'regular', 'label' => $this->__('From'), 'formatted_value' => Mage::helper('core')->currency($min, true, false)));
         }
     }
 }
 /**
  * Add action info to xml
  *
  * @param Mage_XmlConnect_Model_Simplexml_Element $imageXml
  * @param int $imageId
  * @return Mage_XmlConnect_Block_Homebanners
  */
 protected function _addImageAction(Mage_XmlConnect_Model_Simplexml_Element $imageXml, $imageId)
 {
     $imageActionData = Mage::helper('xmlconnect')->getApplication()->getImageActionModel()->getImageActionData($imageId);
     if (empty($imageActionData)) {
         return $this;
     }
     switch ($imageActionData['action_type']) {
         case Mage_XmlConnect_Model_ImageAction::ACTION_TYPE_CMS:
             $page = Mage::getModel('cms/page')->setStoreId(Mage::app()->getStore()->getId())->load($imageActionData['entity_action'], 'identifier');
             if ($page->getId()) {
                 $actionXml = $imageXml->addCustomChild('action', null, array('type' => $imageActionData['action_type']));
                 $actionXml->addCustomChild('attribute', $imageActionData['entity_action'], array('name' => 'id'));
                 $actionXml->addCustomChild('attribute', $page->getTitle(), array('name' => 'title'));
             }
             break;
         case Mage_XmlConnect_Model_ImageAction::ACTION_TYPE_PRODUCT:
             $product = Mage::getModel('catalog/product')->load($imageActionData['entity_action']);
             if ($product->getId()) {
                 $actionXml = $imageXml->addCustomChild('action', null, array('type' => $imageActionData['action_type']));
                 $actionXml->addCustomChild('attribute', $imageActionData['entity_action'], array('name' => 'id'));
             }
             break;
         case Mage_XmlConnect_Model_ImageAction::ACTION_TYPE_CATEGORY:
             $category = Mage::getModel('catalog/category')->load($imageActionData['entity_action']);
             if ($category->getEntityId()) {
                 $actionXml = $imageXml->addCustomChild('action', null, array('type' => $imageActionData['action_type']));
                 $actionXml->addCustomChild('attribute', $imageActionData['entity_action'], array('name' => 'id'));
             }
             break;
         default:
             Mage::throwException($this->__('Action type doesn\'t recognized.'));
             break;
     }
     return $this;
 }
 /**
  * Add last search terms info to xml object
  *
  * @param Mage_XmlConnect_Model_Simplexml_Element $xmlObj
  * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_TopSearchTerms
  */
 public function addTopSearchTermsToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $xmlObj)
 {
     foreach (Mage::helper('xmlconnect/adminApplication')->getSwitcherList() as $storeId) {
         $this->_clearCollection()->_initCollection($storeId);
         $valuesXml = $xmlObj->addCustomChild('values', null, array('store_id' => $storeId ? $storeId : Mage_XmlConnect_Helper_AdminApplication::ALL_STORE_VIEWS));
         if (!count($this->getCollection()->getItems()) > 0) {
             continue;
         }
         foreach ($this->getCollection()->getItems() as $item) {
             $itemListXml = $valuesXml->addCustomChild('item');
             $itemListXml->addCustomChild('name', $item->getName(), array('label' => $this->__('Search Term')));
             $itemListXml->addCustomChild('num_results', $item->getNumResults(), array('label' => $this->__('Results')));
             $itemListXml->addCustomChild('popularity', $item->getPopularity(), array('label' => $this->__('Number of Uses')));
         }
     }
     return $this;
 }
Beispiel #28
0
 /**
  * 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();
 }
 /**
  * Add cart totals data to xml object
  *
  * @param Mage_XmlConnect_Model_Simplexml_Element $xmlObj
  * @return Mage_XmlConnect_Block_Adminhtml_Connect_Dashboard_GraphTotalsData
  */
 public function addTotalsDataToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $xmlObj)
 {
     $dataValuesXml = $xmlObj->addCustomChild('chart_totals');
     foreach (Mage::helper('xmlconnect/adminApplication')->getSwitcherList() as $storeFilter) {
         $storeId = $storeFilter ? $storeFilter : null;
         $totalsXml = $dataValuesXml->addCustomChild('totals', null, array('store_id' => $storeId ? $storeId : Mage_XmlConnect_Helper_AdminApplication::ALL_STORE_VIEWS));
         foreach ($this->getRangeOptions() as $rangeFilter) {
             $this->_initCollection($storeId, $rangeFilter['value']);
             $valuesXml = $totalsXml->addCustomChild('values', null, array('range_id' => $rangeFilter['value']));
             foreach ($this->getTotals() as $total) {
                 $totalValue = $valuesXml->escapeXml($total['value'] . $total['decimals']);
                 $valuesXml->addCustomChild('item', $totalValue, array('label' => $total['label']));
             }
             $this->_clearTotals();
         }
     }
     return $this;
 }
Beispiel #30
0
 /**
  * Appends $source to current node
  *
  * @param Mage_XmlConnect_Model_Simplexml_Element $source
  * @return Mage_XmlConnect_Model_Simplexml_Element
  */
 public function appendChild($source)
 {
     if (sizeof($source->children())) {
         $name = $source->getName();
         $child = $this->addChild($name);
     } else {
         $child = $this->addChild($source->getName(), $this->xmlentities($source));
     }
     $child->setParent($this);
     $attributes = $source->attributes();
     foreach ($attributes as $key => $value) {
         $child->addAttribute($key, $this->xmlAttribute($value));
     }
     foreach ($source->children() as $sourceChild) {
         $child->appendChild($sourceChild);
     }
     return $this;
 }