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-inventory
Observer
ProductQty.php
Go to the documentation of this file.
1
<?php
7
namespace
Magento\CatalogInventory\Observer
;
8
9
use
Magento\Quote\Model\Quote\Item
as QuoteItem;
10
14
class
ProductQty
15
{
22
public
function
getProductQty
($relatedItems)
23
{
24
$items
= [];
25
foreach
($relatedItems as
$item
) {
26
$productId
=
$item
->getProductId();
27
if
(!
$productId
) {
28
continue
;
29
}
30
$children
=
$item
->getChildrenItems();
31
if
(
$children
) {
32
foreach
(
$children
as $childItem) {
33
$this->
_addItemToQtyArray
($childItem,
$items
);
34
}
35
}
else
{
36
$this->
_addItemToQtyArray
($item,
$items
);
37
}
38
}
39
return
$items
;
40
}
41
49
protected
function
_addItemToQtyArray
(QuoteItem
$quoteItem
, &
$items
)
50
{
51
$productId
=
$quoteItem
->getProductId();
52
if
(!
$productId
) {
53
return
;
54
}
55
if
(isset(
$items
[
$productId
])) {
56
$items
[
$productId
] +=
$quoteItem
->getTotalQty();
57
}
else
{
58
$items
[
$productId
] =
$quoteItem
->getTotalQty();
59
}
60
}
61
}
$productId
$productId
Definition:
website_attribute_sync.php:26
$item
$item
Definition:
partial_invoice.php:27
Magento\Quote\Model\Quote\Item
Definition:
RepositoryTest.php:6
$quoteItem
$quoteItem
Definition:
quote.php:38
Magento\CatalogInventory\Observer
Definition:
AddStockItemsObserverTest.php:7
$children
$children
Definition:
actions.phtml:11
Magento\CatalogInventory\Observer\ProductQty
Definition:
ProductQty.php:14
Magento\CatalogInventory\Observer\ProductQty\_addItemToQtyArray
_addItemToQtyArray(QuoteItem $quoteItem, &$items)
Definition:
ProductQty.php:49
Magento\CatalogInventory\Observer\ProductQty\getProductQty
getProductQty($relatedItems)
Definition:
ProductQty.php:22
$items
$items
Definition:
order_rollback.php:21