00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 class Mage_Sales_Block_Order_Item_Renderer_Default extends Mage_Core_Block_Template
00035 {
00036 public function setItem(Varien_Object $item)
00037 {
00038 $this->setData('item', $item);
00039 return $this;
00040 }
00041
00042 public function getItem()
00043 {
00044 return $this->_getData('item');
00045 }
00046
00047
00048
00049
00050
00051
00052 public function getOrder()
00053 {
00054 return $this->getOrderItem()->getOrder();
00055 }
00056
00057
00058 public function getOrderItem()
00059 {
00060 if ($this->getItem() instanceof Mage_Sales_Model_Order_Item) {
00061 return $this->getItem();
00062 } else {
00063 return $this->getItem()->getOrderItem();
00064 }
00065 }
00066
00067 public function getItemOptions()
00068 {
00069 $result = array();
00070 if ($options = $this->getOrderItem()->getProductOptions()) {
00071 if (isset($options['options'])) {
00072 $result = array_merge($result, $options['options']);
00073 }
00074 if (isset($options['additional_options'])) {
00075 $result = array_merge($result, $options['additional_options']);
00076 }
00077 if (isset($options['attributes_info'])) {
00078 $result = array_merge($result, $options['attributes_info']);
00079 }
00080 }
00081 return $result;
00082 }
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104 public function getFormatedOptionValue($optionValue)
00105 {
00106 $optionInfo = array();
00107
00108
00109 if (is_array($optionValue)) {
00110 if (isset($optionValue['option_id'])) {
00111 $optionInfo = $optionValue;
00112 if (isset($optionInfo['value'])) {
00113 $optionValue = $optionInfo['value'];
00114 }
00115 } elseif (isset($optionValue['value'])) {
00116 $optionValue = $optionValue['value'];
00117 }
00118 }
00119
00120
00121 if (isset($optionInfo['custom_view']) && $optionInfo['custom_view']) {
00122 $_default = array('value' => $optionValue);
00123 if (isset($optionInfo['option_type'])) {
00124 try {
00125 $group = Mage::getModel('catalog/product_option')->groupFactory($optionInfo['option_type']);
00126 return array('value' => $group->getCustomizedView($optionInfo));
00127 } catch (Exception $e) {
00128 return $_default;
00129 }
00130 }
00131 return $_default;
00132 }
00133
00134
00135 $result = array();
00136 if (is_array($optionValue)) {
00137 $_truncatedValue = implode("\n", $optionValue);
00138 $_truncatedValue = nl2br($_truncatedValue);
00139 return array('value' => $_truncatedValue);
00140 } else {
00141 $_truncatedValue = Mage::helper('core/string')->truncate($optionValue, 55, '');
00142 $_truncatedValue = nl2br($_truncatedValue);
00143 }
00144
00145 $result = array('value' => $_truncatedValue);
00146
00147 if (Mage::helper('core/string')->strlen($optionValue) > 55) {
00148 $result['value'] = $result['value'] . ' <a href="#" class="dots" onclick="return false">...</a>';
00149 $optionValue = nl2br($optionValue);
00150 $result = array_merge($result, array('full_view' => $optionValue));
00151 }
00152
00153 return $result;
00154 }
00155
00156
00157
00158
00159
00160
00161 public function getSku()
00162 {
00163 if ($this->getOrderItem()->getProductType() == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE) {
00164 return $this->getOrderItem()->getProductOptionByCode('simple_sku');
00165 }
00166 return $this->getItem()->getSku();
00167 }
00168 }