Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
RegistryLocator.php
Go to the documentation of this file.
1 <?php
8 
13 
18 {
22  private $registry;
23 
27  private $product;
28 
32  private $store;
33 
37  public function __construct(Registry $registry)
38  {
39  $this->registry = $registry;
40  }
41 
46  public function getProduct()
47  {
48  if (null !== $this->product) {
49  return $this->product;
50  }
51 
52  if ($product = $this->registry->registry('current_product')) {
53  return $this->product = $product;
54  }
55 
56  throw new NotFoundException(__("The product wasn't registered."));
57  }
58 
63  public function getStore()
64  {
65  if (null !== $this->store) {
66  return $this->store;
67  }
68 
69  if ($store = $this->registry->registry('current_store')) {
70  return $this->store = $store;
71  }
72 
73  throw new NotFoundException(__("The store wasn't registered. Verify the store and try again."));
74  }
75 
79  public function getWebsiteIds()
80  {
81  return $this->getProduct()->getWebsiteIds();
82  }
83 
87  public function getBaseCurrencyCode()
88  {
89  return $this->getStore()->getBaseCurrencyCode();
90  }
91 }
__()
Definition: __.php:13