本文整理汇总了PHP中Mage_XmlConnect_Model_Simplexml_Element::addAttribute方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_XmlConnect_Model_Simplexml_Element::addAttribute方法的具体用法?PHP Mage_XmlConnect_Model_Simplexml_Element::addAttribute怎么用?PHP Mage_XmlConnect_Model_Simplexml_Element::addAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_XmlConnect_Model_Simplexml_Element
的用法示例。
在下文中一共展示了Mage_XmlConnect_Model_Simplexml_Element::addAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _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();
}
示例2: 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));
}
}
}
示例3: addPaymentInfoToXmlObj
/**
* Add Check / Money order 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 ($this->getInfo()->getAdditionalData()) {
if ($this->getPayableTo()) {
$orderItemXmlObj->addCustomChild('item', $this->getPayableTo(), array('label' => Mage::helper('sales')->__('Make Check payable to:')));
}
if ($this->getMailingAddress()) {
$orderItemXmlObj->addCustomChild('item', $this->getMailingAddress(), array('label' => Mage::helper('payment')->__('Send Check to:')));
}
}
}
示例4: _addPriceToXmlObj
/**
* Add price details to xml object
*
* @param Mage_XmlConnect_Model_Simplexml_Element $xmlObj
* @param Mage_Sales_Model_Quote_Address_Rate $rate
* @return Mage_XmlConnect_Block_Cart_Paypal_Mecl_Shippingmethods
*/
protected function _addPriceToXmlObj($xmlObj, $rate)
{
$price = $this->_getShippingPrice($rate->getPrice(), $this->helper('tax')->displayShippingPriceIncludingTax());
$incl = $this->_getShippingPrice($rate->getPrice(), true);
$renderedInclTax = '';
if ($incl != $price && $this->helper('tax')->displayShippingBothPrices()) {
$inclTaxFormat = ' (%s %s)';
$renderedInclTax = sprintf($inclTaxFormat, Mage::helper('tax')->__('Incl. Tax'), $incl);
}
$price .= $renderedInclTax;
$xmlObj->addAttribute('price', $rate->getPrice() * 1);
$xmlObj->addAttribute('formatted_price', $xmlObj->escapeXml($price));
return $this;
}
示例5: addPaymentInfoToXmlObj
/**
* 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));
}
}
}
示例6: _addValue
/**
* Add value and options to select
*
* @param Mage_XmlConnect_Model_Simplexml_Element $xmlObj
* @return Mage_XmlConnect_Model_Simplexml_Form_Element_Select
*/
protected function _addValue(Mage_XmlConnect_Model_Simplexml_Element $xmlObj)
{
$value = $this->getEscapedValue();
if ($value !== null) {
$xmlObj->addAttribute('value', $xmlObj->xmlAttribute($value));
}
$this->_addOptions($xmlObj);
return $this;
}
示例7: getProductCustomOptionsXmlObject
/**
* Create produc custom options Mage_XmlConnect_Model_Simplexml_Element object
*
* @param Mage_Catalog_Model_Product $product
* @return Mage_XmlConnect_Model_Simplexml_Element
*/
public function getProductCustomOptionsXmlObject(Mage_Catalog_Model_Product $product)
{
$xmlModel = new Mage_XmlConnect_Model_Simplexml_Element('<product></product>');
$optionsNode = $xmlModel->addChild('options');
if (!$product->getId()) {
return $xmlModel;
}
$xmlModel->addAttribute('id', $product->getId());
if (!$product->isSaleable() || !sizeof($product->getOptions())) {
return $xmlModel;
}
foreach ($product->getOptions() as $option) {
$optionNode = $optionsNode->addChild('option');
$type = $this->_getOptionTypeForXmlByRealType($option->getType());
$code = 'options[' . $option->getId() . ']';
if ($type == self::OPTION_TYPE_CHECKBOX) {
$code .= '[]';
}
$optionNode->addAttribute('code', $code);
$optionNode->addAttribute('type', $type);
$optionNode->addAttribute('label', $xmlModel->xmlentities(strip_tags($option->getTitle())));
if ($option->getIsRequire()) {
$optionNode->addAttribute('is_required', 1);
}
/**
* Process option price
*/
$price = Mage::helper('xmlconnect')->formatPriceForXml($option->getPrice());
if ($price > 0.0) {
$optionNode->addAttribute('price', $price);
$formatedPrice = Mage::app()->getStore($product->getStoreId())->formatPrice($price, false);
$optionNode->addAttribute('formated_price', $formatedPrice);
}
if ($type == self::OPTION_TYPE_CHECKBOX || $type == self::OPTION_TYPE_SELECT) {
foreach ($option->getValues() as $value) {
$valueNode = $optionNode->addChild('value');
$valueNode->addAttribute('code', $value->getId());
$valueNode->addAttribute('label', $xmlModel->xmlentities(strip_tags($value->getTitle())));
$price = Mage::helper('xmlconnect')->formatPriceForXml($value->getPrice());
if ($price > 0.0) {
$valueNode->addAttribute('price', $price);
$formatedPrice = $this->_formatPriceString($price, $product);
$valueNode->addAttribute('formated_price', $formatedPrice);
}
}
}
}
return $xmlModel;
}
示例8: 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();
}
示例9: _addMessage
/**
* Add validator message for validator rule
*
* @throws Mage_Core_Exception
* @param Mage_XmlConnect_Model_Simplexml_Element $xmlObj
* @return Mage_XmlConnect_Model_Simplexml_Form_Abstract
*/
protected function _addMessage(Mage_XmlConnect_Model_Simplexml_Element $xmlObj)
{
if ($this->getMessage()) {
$message = $this->getMessage();
} elseif (array_key_exists($this->getType(), $this->getValidatorTypeMessages())) {
$message = $this->_validatorTypeMessages[$this->getType()];
} else {
Mage::throwException(Mage::helper('xmlconnect')->__('"message" attribute is required for "%s" validator rule.', $this->getType()));
}
$xmlObj->addAttribute('message', $xmlObj->xmlAttribute($message));
return $this;
}
示例10: _addWeeeToXmlObj
/**
* Add weee tax product info to xml object
*
* @param Mage_XmlConnect_Model_Simplexml_Element $priceXmlObj
* @param bool $subtotalFlag use true to get subtotal product info
* @return Mage_XmlConnect_Model_Simplexml_Element
*/
protected function _addWeeeToXmlObj(Mage_XmlConnect_Model_Simplexml_Element $priceXmlObj, $subtotalFlag = false)
{
$_item = $this->getItem();
$weeeXmlObj = $priceXmlObj->addCustomChild('weee');
if ($subtotalFlag) {
$_incl = $this->helper('checkout')->getSubtotalInclTax($_item);
} else {
$_incl = $this->helper('checkout')->getPriceInclTax($_item);
}
$typeOfDisplay2 = Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales');
if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales') && $_item->getWeeeTaxAppliedAmount()) {
foreach (Mage::helper('weee')->getApplied($_item) as $tax) {
if ($subtotalFlag) {
$amount = $tax['row_amount'];
} else {
$amount = $tax['amount'];
}
$weeeXmlObj->addCustomChild('item', null, array('name' => $tax['title'], 'amount' => $this->_formatPrice($amount)));
}
} elseif ($_item->getWeeeTaxAppliedAmount() && ($typeOfDisplay2 || Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales'))) {
foreach (Mage::helper('weee')->getApplied($_item) as $tax) {
if ($subtotalFlag) {
$amount = $tax['row_amount_incl_tax'];
} else {
$amount = $tax['amount_incl_tax'];
}
$weeeXmlObj->addCustomChild('item', null, array('name' => $tax['title'], 'amount' => $this->_formatPrice($amount)));
}
}
if ($typeOfDisplay2 && $_item->getWeeeTaxAppliedAmount()) {
if ($subtotalFlag) {
$totalExcl = $_item->getRowTotal() + $_item->getWeeeTaxAppliedRowAmount() + $_item->getWeeeTaxRowDisposition();
} else {
$totalExcl = $_item->getCalculationPrice() + $_item->getWeeeTaxAppliedAmount() + $_item->getWeeeTaxDisposition();
}
$totalExcl = $this->_formatPrice($totalExcl);
$priceXmlObj->addAttribute('total_excluding_tax', $priceXmlObj->escapeXml($totalExcl));
}
if ($typeOfDisplay2 && $_item->getWeeeTaxAppliedAmount()) {
if ($subtotalFlag) {
$totalIncl = $_incl + $_item->getWeeeTaxAppliedRowAmount();
} else {
$totalIncl = $_incl + $_item->getWeeeTaxAppliedAmount();
}
$totalIncl = $this->_formatPrice($totalIncl);
$priceXmlObj->addAttribute('total_including_tax', $priceXmlObj->escapeXml($totalIncl));
}
return $priceXmlObj;
}
示例11: addPaymentInfoToXmlObj
/**
* Add Purchase Order 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()));
$orderItemXmlObj->addCustomChild('item', $this->getInfo()->getPoNumber(), array('label' => Mage::helper('sales')->__('Purchase Order Number:')));
}
示例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)
{
if ($this->getEscapedValue()) {
$xmlObj->addAttribute('value', $xmlObj->xmlAttribute($this->getEscapedValue()));
}
return $this;
}
示例13: _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)
{
$xmlObj->addAttribute('value', (int) $this->getValue());
return $this;
}
示例14: _addName
/**
* Add form name to element
*
* @param Mage_XmlConnect_Model_Simplexml_Element $xmlObj
* @return Mage_XmlConnect_Model_Simplexml_Form_Abstract
*/
protected function _addName(Mage_XmlConnect_Model_Simplexml_Element $xmlObj)
{
if ($this->getName()) {
$name = $this->getName();
} elseif ($this->getNameRequired()) {
$name = $this->getXmlId();
}
if (isset($name)) {
$xmlObj->addAttribute('name', $xmlObj->xmlAttribute($name));
}
return $this;
}
示例15: _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();
}