Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
module-catalog
Model
Locator
RegistryLocator.php
Go to the documentation of this file.
1
<?php
7
namespace
Magento\Catalog\Model\Locator
;
8
9
use
Magento\Catalog\Api\Data\ProductInterface
;
10
use
Magento\Framework\Exception\NotFoundException
;
11
use
Magento\Framework\Registry
;
12
use
Magento\Store\Api\Data\StoreInterface
;
13
17
class
RegistryLocator
implements
LocatorInterface
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
}
Magento\Catalog\Model\Locator\RegistryLocator
Definition:
RegistryLocator.php:17
Magento\Catalog\Model\Locator\RegistryLocator\__construct
__construct(Registry $registry)
Definition:
RegistryLocator.php:37
__
__()
Definition:
__.php:13
$registry
$registry
Definition:
bundle_product_with_not_visible_children_rollback.php:16
Magento\Catalog\Model\Locator
Definition:
LocatorInterface.php:6
Magento\Framework\Exception\NotFoundException
Definition:
NotFoundException.php:12
Magento\Catalog\Model\Locator\LocatorInterface
Definition:
LocatorInterface.php:17
Magento\Catalog\Model\Locator\RegistryLocator\getBaseCurrencyCode
getBaseCurrencyCode()
Definition:
RegistryLocator.php:87
Magento\Catalog\Model\Locator\RegistryLocator\getWebsiteIds
getWebsiteIds()
Definition:
RegistryLocator.php:79
Magento\Store\Api\Data\StoreInterface
Definition:
StoreInterface.php:14
Magento\Framework\Registry
Definition:
Registry.php:18
Magento\Catalog\Model\Locator\RegistryLocator\getProduct
getProduct()
Definition:
RegistryLocator.php:46
Magento\Catalog\Api\Data\ProductInterface
Definition:
ProductInterface.php:14
Magento\Catalog\Model\Locator\RegistryLocator\getStore
getStore()
Definition:
RegistryLocator.php:63