Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
PurchasedPrice.php
Go to the documentation of this file.
1 <?php
7 
12 
16 class PurchasedPrice extends Column
17 {
21  protected $priceFormatter;
22 
32  public function __construct(
36  array $components = [],
37  array $data = []
38  ) {
39  $this->priceFormatter = $priceFormatter;
40  parent::__construct($context, $uiComponentFactory, $components, $data);
41  }
42 
49  public function prepareDataSource(array $dataSource)
50  {
51  if (isset($dataSource['data']['items'])) {
52  foreach ($dataSource['data']['items'] as & $item) {
53  $currencyCode = isset($item['order_currency_code']) ? $item['order_currency_code'] : null;
54  $item[$this->getData('name')] =
55  $this->priceFormatter->format(
56  $item[$this->getData('name')],
57  false,
58  null,
59  null,
60  $currencyCode
61  );
62  }
63  }
64 
65  return $dataSource;
66  }
67 }
__construct(ContextInterface $context, UiComponentFactory $uiComponentFactory, PriceCurrencyInterface $priceFormatter, array $components=[], array $data=[])