Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
DefaultItems.php
Go to the documentation of this file.
1 <?php
7 
10 use Magento\Sales\Model\Order\Item as OrderItem;
11 
20 {
26  public function getOrder()
27  {
28  return $this->getItem()->getOrder();
29  }
30 
34  public function getItemOptions()
35  {
36  $result = [];
37  if ($options = $this->getItem()->getOrderItem()->getProductOptions()) {
38  if (isset($options['options'])) {
39  $result = array_merge($result, $options['options']);
40  }
41  if (isset($options['additional_options'])) {
42  $result = array_merge($result, $options['additional_options']);
43  }
44  if (isset($options['attributes_info'])) {
45  $result = array_merge($result, $options['attributes_info']);
46  }
47  }
48 
49  return $result;
50  }
51 
56  public function getValueHtml($value)
57  {
58  if (is_array($value)) {
59  return sprintf(
60  '%d',
61  $value['qty']
62  ) . ' x ' . $this->escapeHtml(
63  $value['title']
64  ) . " " . $this->getItem()->getOrder()->formatPrice(
65  $value['price']
66  );
67  } else {
68  return $this->escapeHtml($value);
69  }
70  }
71 
76  public function getSku($item)
77  {
78  if ($item->getOrderItem()->getProductOptionByCode('simple_sku')) {
79  return $item->getOrderItem()->getProductOptionByCode('simple_sku');
80  } else {
81  return $item->getSku();
82  }
83  }
84 
91  {
92  return $this->getLayout()->getBlock('additional.product.info');
93  }
94 
101  public function getItemPrice($item)
102  {
103  $block = $this->getLayout()->getBlock('item_price');
104  $block->setItem($item);
105  return $block->toHtml();
106  }
107 }
$block
Definition: block.php:8
$value
Definition: gender.phtml:16