Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AbstractCreate.php
Go to the documentation of this file.
1 <?php
7 
11 
19 {
25  protected $_sessionQuote;
26 
32  protected $_orderCreate;
33 
37  protected $priceCurrency;
38 
46  public function __construct(
47  \Magento\Backend\Block\Template\Context $context,
48  \Magento\Backend\Model\Session\Quote $sessionQuote,
49  \Magento\Sales\Model\AdminOrder\Create $orderCreate,
51  array $data = []
52  ) {
53  $this->priceCurrency = $priceCurrency;
54  $this->_sessionQuote = $sessionQuote;
55  $this->_orderCreate = $orderCreate;
56  parent::__construct($context, $data);
57  }
58 
64  public function getCreateOrderModel()
65  {
66  return $this->_orderCreate;
67  }
68 
74  protected function _getSession()
75  {
76  return $this->_sessionQuote;
77  }
78 
84  public function getQuote()
85  {
86  return $this->_getSession()->getQuote();
87  }
88 
94  public function getCustomerId()
95  {
96  return $this->_getSession()->getCustomerId();
97  }
98 
104  public function getStore()
105  {
106  return $this->_getSession()->getStore();
107  }
108 
114  public function getStoreId()
115  {
116  return $this->_getSession()->getStoreId();
117  }
118 
125  public function formatPrice($value)
126  {
127  return $this->priceCurrency->format(
128  $value,
129  true,
130  PriceCurrencyInterface::DEFAULT_PRECISION,
131  $this->getStore()
132  );
133  }
134 
139  public function getItemPrice(Product $product)
140  {
141  $price = $product->getPriceInfo()->getPrice(FinalPrice::PRICE_CODE)->getValue();
142  return $this->convertPrice($price);
143  }
144 
152  public function convertPrice($value, $format = true)
153  {
154  return $format
155  ? $this->priceCurrency->convertAndFormat(
156  $value,
157  true,
158  PriceCurrencyInterface::DEFAULT_PRECISION,
159  $this->getStore()
160  )
161  : $this->priceCurrency->convert($value, $this->getStore());
162  }
163 
171  public function getProduct($item)
172  {
173  if ($item instanceof Product) {
174  $product = $item;
175  } else {
176  $product = $item->getProduct();
177  }
178 
179  return $product;
180  }
181 }
$price
__construct(\Magento\Backend\Block\Template\Context $context, \Magento\Backend\Model\Session\Quote $sessionQuote, \Magento\Sales\Model\AdminOrder\Create $orderCreate, PriceCurrencyInterface $priceCurrency, array $data=[])
$value
Definition: gender.phtml:16
$format
Definition: list.phtml:12