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-checkout
CustomerData
ItemPool.php
Go to the documentation of this file.
1
<?php
7
namespace
Magento\Checkout\CustomerData
;
8
9
use
Magento\Framework\Exception\LocalizedException
;
10
use
Magento\Framework\ObjectManagerInterface
;
11
use
Magento\Quote\Model\Quote\Item
;
12
16
class
ItemPool
implements
ItemPoolInterface
17
{
23
protected
$objectManager
;
24
30
protected
$defaultItemId
;
31
37
protected
$itemMap
;
38
47
public
function
__construct
(
48
ObjectManagerInterface
$objectManager
,
49
$defaultItemId
,
50
array
$itemMap
= []
51
) {
52
$this->objectManager =
$objectManager
;
53
$this->defaultItemId =
$defaultItemId
;
54
$this->itemMap =
$itemMap
;
55
}
56
61
public
function
getItemData
(
Item
$item
)
62
{
63
return
$this->
get
($item->
getProductType
())->
getItemData
(
$item
);
64
}
65
73
protected
function
get
(
$type
)
74
{
75
$itemId = isset($this->itemMap[
$type
]) ? $this->itemMap[
$type
] :
$this->defaultItemId
;
76
$item
= $this->objectManager->get($itemId);
77
78
if
(!
$item
instanceof
ItemInterface
) {
79
throw
new
LocalizedException
(
80
__
(
'%1 doesn\'t extend \Magento\Checkout\CustomerData\ItemInterface'
,
$type
)
81
);
82
}
83
return
$item
;
84
}
85
}
Magento\Framework\Exception\LocalizedException
Definition:
LocalizedException.php:17
Magento\Checkout\CustomerData\ItemPoolInterface
Definition:
ItemPoolInterface.php:14
Magento\Checkout\CustomerData\ItemPool
Definition:
ItemPool.php:16
Magento\Checkout\CustomerData
Definition:
AbstractItem.php:7
Magento\Framework\ObjectManagerInterface
Definition:
ObjectManagerInterface.php:12
Magento\Checkout\CustomerData\ItemPool\$objectManager
$objectManager
Definition:
ItemPool.php:23
__
__()
Definition:
__.php:13
$item
$item
Definition:
partial_invoice.php:27
Magento\Quote\Model\Quote\Item
Definition:
Item.php:98
Magento\Quote\Model\Quote\Item
Definition:
RepositoryTest.php:6
$type
$type
Definition:
item.phtml:13
Magento\Checkout\CustomerData\ItemInterface
Definition:
ItemInterface.php:17
Magento\Checkout\CustomerData\ItemPool\$itemMap
$itemMap
Definition:
ItemPool.php:37
Magento\Checkout\CustomerData\ItemPool\__construct
__construct(ObjectManagerInterface $objectManager, $defaultItemId, array $itemMap=[])
Definition:
ItemPool.php:47
Magento\Checkout\CustomerData\ItemPool\getItemData
getItemData(Item $item)
Definition:
ItemPool.php:61
Magento\Checkout\CustomerData\ItemPool\$defaultItemId
$defaultItemId
Definition:
ItemPool.php:30
Magento\Quote\Model\Quote\Item\getProductType
getProductType()
Definition:
Item.php:524