Skip to content

Commit e3477b4

Browse files
Merge branch 'magento-commerce:2.4-develop' into eav-graphql
2 parents d2bfc53 + 55ca27d commit e3477b4

File tree

146 files changed

+2349
-602
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

146 files changed

+2349
-602
lines changed

app/code/Magento/Authorization/Model/CompositeUserContext.php

+10-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
namespace Magento\Authorization\Model;
88

99
use Magento\Framework\ObjectManager\Helper\Composite as CompositeHelper;
10+
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
1011

1112
/**
1213
* User context.
@@ -17,7 +18,7 @@
1718
* @api
1819
* @since 100.0.2
1920
*/
20-
class CompositeUserContext implements \Magento\Authorization\Model\UserContextInterface
21+
class CompositeUserContext implements \Magento\Authorization\Model\UserContextInterface, ResetAfterRequestInterface
2122
{
2223
/**
2324
* @var UserContextInterface[]
@@ -92,4 +93,12 @@ protected function getUserContext()
9293
}
9394
return $this->chosenUserContext;
9495
}
96+
97+
/**
98+
* @inheritDoc
99+
*/
100+
public function _resetState(): void
101+
{
102+
$this->chosenUserContext = null;
103+
}
95104
}

app/code/Magento/Bundle/Model/Plugin/Frontend/ProductIdentitiesExtender.php

+10-1
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@
99

1010
use Magento\Bundle\Model\Product\Type as BundleType;
1111
use Magento\Catalog\Model\Product as CatalogProduct;
12+
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
1213

1314
/**
1415
* Add child identities to product identities on storefront.
1516
*/
16-
class ProductIdentitiesExtender
17+
class ProductIdentitiesExtender implements ResetAfterRequestInterface
1718
{
1819
/**
1920
* @var BundleType
@@ -68,4 +69,12 @@ private function getChildrenIds($entityId): array
6869

6970
return $this->cacheChildrenIds[$entityId];
7071
}
72+
73+
/**
74+
* @inheritDoc
75+
*/
76+
public function _resetState(): void
77+
{
78+
$this->cacheChildrenIds = [];
79+
}
7180
}

app/code/Magento/Bundle/Model/Plugin/ProductIdentitiesExtender.php

+10-1
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@
99

1010
use Magento\Bundle\Model\Product\Type as BundleType;
1111
use Magento\Catalog\Model\Product as CatalogProduct;
12+
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
1213

1314
/**
1415
* Add parent identities to product identities.
1516
*/
16-
class ProductIdentitiesExtender
17+
class ProductIdentitiesExtender implements ResetAfterRequestInterface
1718
{
1819
/**
1920
* @var BundleType
@@ -68,4 +69,12 @@ private function getParentIdsByChild($entityId): array
6869

6970
return $this->cacheParentIdsByChild[$entityId];
7071
}
72+
73+
/**
74+
* @inheritDoc
75+
*/
76+
public function _resetState(): void
77+
{
78+
$this->cacheParentIdsByChild = [];
79+
}
7180
}

app/code/Magento/Bundle/Model/Product/SelectionProductsDisabledRequired.php

+10-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Magento\Framework\EntityManager\MetadataPool;
1111
use Magento\Catalog\Model\Product\Attribute\Source\Status;
1212
use Magento\Bundle\Model\ResourceModel\Selection as BundleSelection;
13+
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
1314
use Magento\Store\Model\StoreManagerInterface;
1415
use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory as ProductCollectionFactory;
1516
use Magento\Catalog\Model\Product;
@@ -18,7 +19,7 @@
1819
/**
1920
* Class to return ids of options and child products when all products in required option are disabled in bundle product
2021
*/
21-
class SelectionProductsDisabledRequired
22+
class SelectionProductsDisabledRequired implements ResetAfterRequestInterface
2223
{
2324
/**
2425
* @var BundleSelection
@@ -161,4 +162,12 @@ private function getCacheKey(int $bundleId, int $websiteId): string
161162
{
162163
return $bundleId . '-' . $websiteId;
163164
}
165+
166+
/**
167+
* @inheritDoc
168+
*/
169+
public function _resetState(): void
170+
{
171+
$this->productsDisabledRequired = [];
172+
}
164173
}

app/code/Magento/Bundle/Pricing/Adjustment/Calculator.php

+15-3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Magento\Bundle\Pricing\Price\BundleSelectionFactory;
1313
use Magento\Bundle\Pricing\Price\BundleSelectionPrice;
1414
use Magento\Catalog\Model\Product;
15+
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
1516
use Magento\Framework\Pricing\Adjustment\Calculator as CalculatorBase;
1617
use Magento\Framework\Pricing\Amount\AmountFactory;
1718
use Magento\Framework\Pricing\Amount\AmountInterface;
@@ -25,7 +26,7 @@
2526
* Bundle price calculator
2627
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2728
*/
28-
class Calculator implements BundleCalculatorInterface
29+
class Calculator implements BundleCalculatorInterface, ResetAfterRequestInterface
2930
{
3031
/**
3132
* @var CalculatorBase
@@ -214,7 +215,8 @@ protected function getSelectionAmounts(Product $bundleProduct, $searchMin, $useR
214215
* @param Option $option
215216
* @param bool $canSkipRequiredOption
216217
* @return bool
217-
* @deprecated 100.2.0
218+
* @deprecated 100.2.0 Not used anymore.
219+
* @see Nothing
218220
*/
219221
protected function canSkipOption($option, $canSkipRequiredOption)
220222
{
@@ -226,7 +228,8 @@ protected function canSkipOption($option, $canSkipRequiredOption)
226228
*
227229
* @param Product $bundleProduct
228230
* @return bool
229-
* @deprecated 100.2.0
231+
* @deprecated 100.2.0 Not used anymore.
232+
* @see Nothing
230233
*/
231234
protected function hasRequiredOption($bundleProduct)
232235
{
@@ -245,6 +248,7 @@ function ($item) {
245248
* @param Product $saleableItem
246249
* @return \Magento\Bundle\Model\ResourceModel\Option\Collection
247250
* @deprecated 100.2.0
251+
* @see Nothing
248252
*/
249253
protected function getBundleOptions(Product $saleableItem)
250254
{
@@ -425,4 +429,12 @@ public function processOptions($option, $selectionPriceList, $searchMin = true)
425429
}
426430
return $result;
427431
}
432+
433+
/**
434+
* @inheritDoc
435+
*/
436+
public function _resetState(): void
437+
{
438+
$this->optionAmount = [];
439+
}
428440
}

app/code/Magento/Bundle/Pricing/Adjustment/DefaultSelectionPriceListProvider.php

+10-1
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@
1111
use Magento\Catalog\Model\Product;
1212
use Magento\Bundle\Model\Product\Price;
1313
use Magento\Catalog\Helper\Data as CatalogData;
14+
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
1415
use Magento\Store\Model\StoreManagerInterface;
1516
use Magento\Store\Api\WebsiteRepositoryInterface;
1617

1718
/**
1819
* Provide lightweight implementation which uses price index
1920
*/
20-
class DefaultSelectionPriceListProvider implements SelectionPriceListProviderInterface
21+
class DefaultSelectionPriceListProvider implements SelectionPriceListProviderInterface, ResetAfterRequestInterface
2122
{
2223
/**
2324
* @var BundleSelectionFactory
@@ -245,4 +246,12 @@ private function getBundleOptions(Product $saleableItem)
245246
{
246247
return $saleableItem->getTypeInstance()->getOptionsCollection($saleableItem);
247248
}
249+
250+
/**
251+
* @inheritDoc
252+
*/
253+
public function _resetState(): void
254+
{
255+
$this->priceList = [];
256+
}
248257
}

app/code/Magento/Bundle/Pricing/Price/BundleOptions.php

+11-1
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@
88
namespace Magento\Bundle\Pricing\Price;
99

1010
use Magento\Bundle\Pricing\Adjustment\BundleCalculatorInterface;
11+
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
1112
use Magento\Framework\Pricing\SaleableInterface;
1213
use Magento\Framework\Pricing\Amount\AmountInterface;
1314
use Magento\Catalog\Model\Product;
1415

1516
/**
1617
* Bundle option price calculation model.
1718
*/
18-
class BundleOptions
19+
class BundleOptions implements ResetAfterRequestInterface
1920
{
2021
/**
2122
* @var BundleCalculatorInterface
@@ -91,6 +92,7 @@ public function calculateOptions(
9192
/** @var \Magento\Bundle\Pricing\Price\BundleSelectionPrice $selectionPriceList */
9293
$selectionPriceList = $this->calculator->createSelectionPriceList($option, $bundleProduct);
9394
$selectionPriceList = $this->calculator->processOptions($option, $selectionPriceList, $searchMin);
95+
// phpcs:ignore Magento2.Performance.ForeachArrayMerge
9496
$priceList = array_merge($priceList, $selectionPriceList);
9597
}
9698
$amount = $this->calculator->calculateBundleAmount(0., $bundleProduct, $priceList);
@@ -135,4 +137,12 @@ public function getOptionSelectionAmount(
135137

136138
return $this->optionSelectionAmountCache[$cacheKey];
137139
}
140+
141+
/**
142+
* @inheritDoc
143+
*/
144+
public function _resetState(): void
145+
{
146+
$this->optionSelectionAmountCache = [];
147+
}
138148
}

app/code/Magento/Bundle/Pricing/Price/BundleRegularPrice.php

+12-1
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,16 @@
77
namespace Magento\Bundle\Pricing\Price;
88

99
use Magento\Bundle\Pricing\Adjustment\BundleCalculatorInterface;
10+
use Magento\Catalog\Pricing\Price\RegularPrice;
11+
use Magento\Framework\ObjectManager\ResetAfterRequestInterface;
1012
use Magento\Framework\Pricing\Amount\AmountInterface;
1113
use Magento\Catalog\Pricing\Price\CustomOptionPrice;
1214
use Magento\Bundle\Model\Product\Price;
1315

1416
/**
1517
* Bundle product regular price model
1618
*/
17-
class BundleRegularPrice extends \Magento\Catalog\Pricing\Price\RegularPrice implements RegularPriceInterface
19+
class BundleRegularPrice extends RegularPrice implements RegularPriceInterface, ResetAfterRequestInterface
1820
{
1921
/**
2022
* @var BundleCalculatorInterface
@@ -72,4 +74,13 @@ public function getMinimalPrice()
7274
{
7375
return $this->getAmount();
7476
}
77+
78+
/**
79+
* @inheritDoc
80+
*/
81+
public function _resetState(): void
82+
{
83+
$this->maximalPrice = null;
84+
$this->amount = [];
85+
}
7586
}

app/code/Magento/BundleGraphQl/Model/Resolver/BundleItemLinks.php

+18-13
Original file line numberDiff line numberDiff line change
@@ -7,37 +7,43 @@
77

88
namespace Magento\BundleGraphQl\Model\Resolver;
99

10-
use Magento\Framework\Exception\LocalizedException;
11-
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
1210
use Magento\BundleGraphQl\Model\Resolver\Links\Collection;
11+
use Magento\BundleGraphQl\Model\Resolver\Links\CollectionFactory;
12+
use Magento\Framework\App\ObjectManager;
13+
use Magento\Framework\Exception\LocalizedException;
1314
use Magento\Framework\GraphQl\Config\Element\Field;
1415
use Magento\Framework\GraphQl\Query\Resolver\ValueFactory;
1516
use Magento\Framework\GraphQl\Query\ResolverInterface;
17+
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
1618

1719
/**
1820
* @inheritdoc
1921
*/
2022
class BundleItemLinks implements ResolverInterface
2123
{
2224
/**
23-
* @var Collection
25+
* @var CollectionFactory
2426
*/
25-
private $linkCollection;
27+
private CollectionFactory $linkCollectionFactory;
2628

2729
/**
2830
* @var ValueFactory
2931
*/
30-
private $valueFactory;
32+
private ValueFactory $valueFactory;
3133

3234
/**
33-
* @param Collection $linkCollection
35+
* @param Collection $linkCollection Deprecated. Use $linkCollectionFactory instead
3436
* @param ValueFactory $valueFactory
37+
* @param CollectionFactory|null $linkCollectionFactory
38+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
3539
*/
3640
public function __construct(
3741
Collection $linkCollection,
38-
ValueFactory $valueFactory
42+
ValueFactory $valueFactory,
43+
CollectionFactory $linkCollectionFactory = null
3944
) {
40-
$this->linkCollection = $linkCollection;
45+
$this->linkCollectionFactory = $linkCollectionFactory
46+
?: ObjectManager::getInstance()->get(CollectionFactory::class);
4147
$this->valueFactory = $valueFactory;
4248
}
4349

@@ -49,12 +55,11 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value
4955
if (!isset($value['option_id']) || !isset($value['parent_id'])) {
5056
throw new LocalizedException(__('"option_id" and "parent_id" values should be specified'));
5157
}
52-
53-
$this->linkCollection->addIdFilters((int)$value['option_id'], (int)$value['parent_id']);
54-
$result = function () use ($value) {
55-
return $this->linkCollection->getLinksForOptionId((int)$value['option_id']);
58+
$linkCollection = $this->linkCollectionFactory->create();
59+
$linkCollection->addIdFilters((int)$value['option_id'], (int)$value['parent_id']);
60+
$result = function () use ($value, $linkCollection) {
61+
return $linkCollection->getLinksForOptionId((int)$value['option_id']);
5662
};
57-
5863
return $this->valueFactory->create($result);
5964
}
6065
}

0 commit comments

Comments
 (0)