Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
All Data Structures Namespaces Files Functions Variables Pages
DefaultOrder.php
Go to the documentation of this file.
1 <?php
7 
8 use Magento\Sales\Model\Order\Item as OrderItem;
9 
18 {
24  public function getOrder()
25  {
26  return $this->getItem()->getOrder();
27  }
28 
32  public function getItemOptions()
33  {
34  $result = [];
35  if ($options = $this->getItem()->getProductOptions()) {
36  if (isset($options['options'])) {
37  $result = array_merge($result, $options['options']);
38  }
39  if (isset($options['additional_options'])) {
40  $result = array_merge($result, $options['additional_options']);
41  }
42  if (isset($options['attributes_info'])) {
43  $result = array_merge($result, $options['attributes_info']);
44  }
45  }
46 
47  return $result;
48  }
49 
54  public function getValueHtml($value)
55  {
56  if (is_array($value)) {
57  return sprintf(
58  '%d',
59  $value['qty']
60  ) . ' x ' . $this->escapeHtml(
61  $value['title']
62  ) . " " . $this->getItem()->getOrder()->formatPrice(
63  $value['price']
64  );
65  } else {
66  return $this->escapeHtml($value);
67  }
68  }
69 
74  public function getSku($item)
75  {
76  if ($item->getProductOptionByCode('simple_sku')) {
77  return $item->getProductOptionByCode('simple_sku');
78  } else {
79  return $item->getSku();
80  }
81  }
82 
89  {
90  return $this->getLayout()->getBlock('additional.product.info');
91  }
92 
99  public function getItemPrice(OrderItem $item)
100  {
101  $block = $this->getLayout()->getBlock('item_price');
102  $block->setItem($item);
103  return $block->toHtml();
104  }
105 }
$block
Definition: block.php:8
$value
Definition: gender.phtml:16