Skip to content

Commit e58d121

Browse files
committed
Merge branch '2.4-develop' of github.com:adobe-commerce-tier-4/magento2ce into ACP2E-3986
2 parents a07aabd + 963fe57 commit e58d121

File tree

212 files changed

+25855
-1082
lines changed

Some content is hidden

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

212 files changed

+25855
-1082
lines changed

app/bootstrap.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,6 @@
5050
$mask = file_exists($umaskFile) ? octdec(file_get_contents($umaskFile)) : 002;
5151
umask($mask);
5252

53-
if (empty($_SERVER['ENABLE_IIS_REWRITES']) || ($_SERVER['ENABLE_IIS_REWRITES'] != 1)) {
54-
/*
55-
* Unset headers used by IIS URL rewrites.
56-
*/
57-
unset($_SERVER['HTTP_X_REWRITE_URL']);
58-
unset($_SERVER['HTTP_X_ORIGINAL_URL']);
59-
unset($_SERVER['IIS_WasUrlRewritten']);
60-
unset($_SERVER['UNENCODED_URL']);
61-
unset($_SERVER['ORIG_PATH_INFO']);
62-
}
63-
6453
if (
6554
(!empty($_SERVER['MAGE_PROFILER']) || file_exists(BP . '/var/profiler.flag'))
6655
&& isset($_SERVER['HTTP_ACCEPT'])

app/code/Magento/Catalog/Model/ResourceModel/Url.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ protected function _getCategories($categoryIds, $storeId = null, $path = null)
412412
if (!is_array($categoryIds)) {
413413
$categoryIds = [$categoryIds];
414414
}
415-
$isActiveExpr = $connection->getCheckSql('c.value_id > 0', 'c.value', 'c.value');
415+
$isActiveExpr = $connection->getCheckSql('c.value_id IS NOT NULL', 'c.value', 'd.value');
416416
$select = $connection->select()->from(
417417
['main_table' => $this->getTable('catalog_category_entity')],
418418
[

app/code/Magento/Catalog/view/adminhtml/web/js/product-gallery.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,14 @@ define([
355355
imageData.isRemoved = true;
356356
$imageContainer.addClass('removed').hide().find('.is-removed').val(1);
357357

358+
// Reset all image role/type selections to 'no_selection' value
359+
// For each role (like base image, small image, etc.), clears both
360+
// the UI select element and the internal types data structure
361+
$.each(this.options.types, $.proxy(function (index, type) {
362+
this.element.find('.image-' + type.code).val('no_selection');
363+
this.options.types[index].value = 'no_selection';
364+
}, this));
365+
358366
this._contentUpdated();
359367
},
360368

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,27 @@
11
<?php
22
/**
3-
* Copyright 2014 Adobe
3+
* Copyright 2011 Adobe
44
* All Rights Reserved.
55
*/
66

77
/** @var $block \Magento\Catalog\Block\Product\View */
8+
/** @var $escaper \Magento\Framework\Escaper */
9+
10+
$product = $block->getProduct();
811
?>
912

1013
<meta property="og:type" content="product" />
1114
<meta property="og:title"
12-
content="<?= $block->escapeHtmlAttr($block->stripTags($block->getProduct()->getName())) ?>" />
15+
content="<?= $escaper->escapeHtmlAttr($block->stripTags($product->getName())) ?>" />
1316
<meta property="og:image"
14-
content="<?= $block->escapeUrl($block->getImage($block->getProduct(), 'product_base_image')->getImageUrl()) ?>" />
17+
content="<?= $escaper->escapeUrl($block->getImage($product, 'product_base_image')->getImageUrl()) ?>" />
1518
<meta property="og:description"
16-
content="<?= $block->escapeHtmlAttr($block->stripTags($block->getProduct()->getShortDescription())) ?>" />
17-
<meta property="og:url" content="<?= $block->escapeUrl($block->getProduct()->getProductUrl()) ?>" />
18-
<?php if ($priceAmount = $block->getProduct()
19+
content="<?= $escaper->escapeHtmlAttr($block->stripTags($product->getShortDescription())) ?>" />
20+
<meta property="og:url" content="<?= $escaper->escapeUrl($product->getProductUrl()) ?>" />
21+
<?php if ($product->getCanShowPrice() !== false && $priceAmount = $product
1922
->getPriceInfo()
2023
->getPrice(\Magento\Catalog\Pricing\Price\FinalPrice::PRICE_CODE)
2124
->getAmount()):?>
22-
<meta property="product:price:amount" content="<?= $block->escapeHtmlAttr($priceAmount) ?>"/>
25+
<meta property="product:price:amount" content="<?= $escaper->escapeHtmlAttr($priceAmount) ?>"/>
2326
<?= $block->getChildHtml('meta.currency') ?>
2427
<?php endif;?>

app/code/Magento/CatalogRule/Model/Indexer/ReindexRuleProduct.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,18 @@ public function execute(Rule $rule, $batchCount, $useAdditionalTable = false)
129129
continue;
130130
}
131131

132+
if (isset($validationByWebsite['has_antecedent_rule'])) {
133+
$antecedentRuleProductList = array_keys(
134+
$connection->fetchAssoc(
135+
$connection->select()->from($indexTable)
136+
->where('product_id = ?', $productId)
137+
->where('rule_id NOT IN (?)', $rule->getId())
138+
->where('sort_order = ?', $sortOrder)
139+
)
140+
);
141+
$connection->delete($indexTable, ['rule_product_id IN (?)' => $antecedentRuleProductList]);
142+
}
143+
132144
foreach ($customerGroupIds as $customerGroupId) {
133145
if (!array_key_exists($customerGroupId, $excludedWebsites)
134146
|| !in_array((int)$websiteId, array_values($excludedWebsites[$customerGroupId]), true)

app/code/Magento/CatalogRuleConfigurable/Plugin/CatalogRule/Model/Rule/ConfigurableProductHandler.php

Lines changed: 60 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,40 @@
33
* Copyright 2015 Adobe
44
* All Rights Reserved.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\CatalogRuleConfigurable\Plugin\CatalogRule\Model\Rule;
79

8-
use Magento\ConfigurableProduct\Model\Product\Type\Configurable;
910
use Magento\CatalogRuleConfigurable\Plugin\CatalogRule\Model\ConfigurableProductsProvider;
11+
use Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable as ConfigurableProductsResourceModel;
1012

1113
/**
1214
* Add configurable sub products to catalog rule indexer on full reindex
1315
*/
1416
class ConfigurableProductHandler
1517
{
1618
/**
17-
* @var \Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable
19+
* @var ConfigurableProductsResourceModel
1820
*/
19-
private $configurable;
21+
private ConfigurableProductsResourceModel $configurable;
2022

2123
/**
22-
* @var \Magento\CatalogRuleConfigurable\Plugin\CatalogRule\Model\ConfigurableProductsProvider
24+
* @var ConfigurableProductsProvider
2325
*/
24-
private $configurableProductsProvider;
26+
private ConfigurableProductsProvider $configurableProductsProvider;
2527

2628
/**
2729
* @var array
2830
*/
29-
private $childrenProducts = [];
31+
private array $childrenProducts = [];
3032

3133
/**
32-
* @param \Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable $configurable
34+
* @param ConfigurableProductsResourceModel $configurable
3335
* @param ConfigurableProductsProvider $configurableProductsProvider
3436
*/
3537
public function __construct(
36-
\Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable $configurable,
37-
ConfigurableProductsProvider $configurableProductsProvider
38+
ConfigurableProductsResourceModel $configurable,
39+
ConfigurableProductsProvider $configurableProductsProvider
3840
) {
3941
$this->configurable = $configurable;
4042
$this->configurableProductsProvider = $configurableProductsProvider;
@@ -48,40 +50,71 @@ public function __construct(
4850
* @return array
4951
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
5052
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
53+
* @SuppressWarnings(PHPMD.NPathComplexity)
54+
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
5155
*/
5256
public function aroundGetMatchingProductIds(
5357
\Magento\CatalogRule\Model\Rule $rule,
5458
\Closure $proceed
55-
) {
59+
): array {
5660
$productsFilter = $rule->getProductsFilter() ? (array) $rule->getProductsFilter() : [];
5761
if ($productsFilter) {
58-
$parentProductIds = $this->configurable->getParentIdsByChild($productsFilter);
59-
$rule->setProductsFilter(array_unique(array_merge($productsFilter, $parentProductIds)));
62+
$rule->setProductsFilter(
63+
array_unique(
64+
array_merge(
65+
$productsFilter,
66+
$this->configurable->getParentIdsByChild($productsFilter)
67+
)
68+
)
69+
);
6070
}
6171

6272
$productIds = $proceed();
73+
foreach ($productIds as $productId => $productData) {
74+
if ($this->hasAntecedentRule((int) $productId)) {
75+
$productIds[$productId]['has_antecedent_rule'] = true;
76+
}
77+
}
6378

64-
$configurableProductIds = $this->configurableProductsProvider->getIds(array_keys($productIds));
65-
foreach ($configurableProductIds as $productId) {
66-
if (!isset($this->childrenProducts[$productId])) {
67-
$this->childrenProducts[$productId] = $this->configurable->getChildrenIds($productId)[0];
79+
foreach ($this->configurableProductsProvider->getIds(array_keys($productIds)) as $configurableProductId) {
80+
if (!isset($this->childrenProducts[$configurableProductId])) {
81+
$this->childrenProducts[$configurableProductId] =
82+
$this->configurable->getChildrenIds($configurableProductId)[0];
6883
}
69-
$subProductIds = $this->childrenProducts[$productId];
70-
$parentValidationResult = isset($productIds[$productId])
71-
? array_filter($productIds[$productId])
84+
85+
$parentValidationResult = isset($productIds[$configurableProductId])
86+
? array_filter($productIds[$configurableProductId])
7287
: [];
73-
$processAllChildren = !$productsFilter || in_array($productId, $productsFilter);
74-
foreach ($subProductIds as $subProductId) {
75-
if ($processAllChildren || in_array($subProductId, $productsFilter)) {
76-
$childValidationResult = isset($productIds[$subProductId])
77-
? array_filter($productIds[$subProductId])
88+
$processAllChildren = !$productsFilter || in_array($configurableProductId, $productsFilter);
89+
foreach ($this->childrenProducts[$configurableProductId] as $childrenProductId) {
90+
if ($processAllChildren || in_array($childrenProductId, $productsFilter)) {
91+
$childValidationResult = isset($productIds[$childrenProductId])
92+
? array_filter($productIds[$childrenProductId])
7893
: [];
79-
$productIds[$subProductId] = $parentValidationResult + $childValidationResult;
94+
$productIds[$childrenProductId] = $parentValidationResult + $childValidationResult;
8095
}
81-
8296
}
83-
unset($productIds[$productId]);
97+
unset($productIds[$configurableProductId]);
8498
}
99+
85100
return $productIds;
86101
}
102+
103+
/**
104+
* Check if simple product has previously applied rule.
105+
*
106+
* @param int $productId
107+
* @return bool
108+
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
109+
*/
110+
private function hasAntecedentRule(int $productId): bool
111+
{
112+
foreach ($this->childrenProducts as $parent => $children) {
113+
if (in_array($productId, $children)) {
114+
return true;
115+
}
116+
}
117+
118+
return false;
119+
}
87120
}

app/code/Magento/Cms/Model/Page/DataProvider.php

Lines changed: 18 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
namespace Magento\Cms\Model\Page;
77

88
use Magento\Cms\Api\Data\PageInterface;
9-
use Magento\Cms\Api\PageRepositoryInterface;
10-
use Magento\Cms\Model\PageFactory;
9+
use Magento\Cms\Model\Page\Service\PageService;
1110
use Magento\Cms\Model\ResourceModel\Page\CollectionFactory;
1211
use Magento\Framework\App\ObjectManager;
1312
use Magento\Framework\App\Request\DataPersistorInterface;
@@ -33,11 +32,6 @@ class DataProvider extends ModifierPoolDataProvider
3332
*/
3433
protected $loadedData;
3534

36-
/**
37-
* @var PageRepositoryInterface
38-
*/
39-
private $pageRepository;
40-
4135
/**
4236
* @var AuthorizationInterface
4337
*/
@@ -49,14 +43,9 @@ class DataProvider extends ModifierPoolDataProvider
4943
private $request;
5044

5145
/**
52-
* @var CustomLayoutManagerInterface
46+
* @var PageService
5347
*/
54-
private $customLayoutManager;
55-
56-
/**
57-
* @var PageFactory
58-
*/
59-
private $pageFactory;
48+
private $pageService;
6049

6150
/**
6251
* @var LoggerInterface
@@ -74,9 +63,7 @@ class DataProvider extends ModifierPoolDataProvider
7463
* @param PoolInterface|null $pool
7564
* @param AuthorizationInterface|null $auth
7665
* @param RequestInterface|null $request
77-
* @param CustomLayoutManagerInterface|null $customLayoutManager
78-
* @param PageRepositoryInterface|null $pageRepository
79-
* @param PageFactory|null $pageFactory
66+
* @param PageService|null $pageService
8067
* @param LoggerInterface|null $logger
8168
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
8269
*/
@@ -91,9 +78,7 @@ public function __construct(
9178
?PoolInterface $pool = null,
9279
?AuthorizationInterface $auth = null,
9380
?RequestInterface $request = null,
94-
?CustomLayoutManagerInterface $customLayoutManager = null,
95-
?PageRepositoryInterface $pageRepository = null,
96-
?PageFactory $pageFactory = null,
81+
?PageService $pageService = null,
9782
?LoggerInterface $logger = null
9883
) {
9984
parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data, $pool);
@@ -102,10 +87,7 @@ public function __construct(
10287
$this->auth = $auth ?? ObjectManager::getInstance()->get(AuthorizationInterface::class);
10388
$this->meta = $this->prepareMeta($this->meta);
10489
$this->request = $request ?? ObjectManager::getInstance()->get(RequestInterface::class);
105-
$this->customLayoutManager = $customLayoutManager
106-
?? ObjectManager::getInstance()->get(CustomLayoutManagerInterface::class);
107-
$this->pageRepository = $pageRepository ?? ObjectManager::getInstance()->get(PageRepositoryInterface::class);
108-
$this->pageFactory = $pageFactory ?: ObjectManager::getInstance()->get(PageFactory::class);
90+
$this->pageService = $pageService ?: ObjectManager::getInstance()->get(PageService::class);
10991
$this->logger = $logger ?: ObjectManager::getInstance()->get(LoggerInterface::class);
11092
}
11193

@@ -150,22 +132,16 @@ private function getCurrentPage(): PageInterface
150132
{
151133
$pageId = $this->getPageId();
152134
if ($pageId) {
153-
try {
154-
$page = $this->pageRepository->getById($pageId);
155-
} catch (LocalizedException $exception) {
156-
$page = $this->pageFactory->create();
157-
}
158-
159-
return $page;
135+
return $this->pageService->getPageById($pageId);
160136
}
161137

162138
$data = $this->dataPersistor->get('cms_page');
163139
if (empty($data)) {
164-
return $this->pageFactory->create();
140+
return $this->pageService->createPageFactory();
165141
}
166142
$this->dataPersistor->clear('cms_page');
167143

168-
return $this->pageFactory->create()
144+
return $this->pageService->createPageFactory()
169145
->setData($data);
170146
}
171147

@@ -215,12 +191,15 @@ public function getMeta()
215191

216192
$page = null;
217193
try {
218-
$page = $this->pageRepository->getById($this->getPageId());
219-
if ($page->getCustomLayoutUpdateXml() || $page->getLayoutUpdateXml()) {
220-
$options[] = ['label' => 'Use existing layout update XML', 'value' => '_existing_'];
221-
}
222-
foreach ($this->customLayoutManager->fetchAvailableFiles($page) as $layoutFile) {
223-
$options[] = ['label' => $layoutFile, 'value' => $layoutFile];
194+
$pageId = $this->getPageId();
195+
if ($pageId) {
196+
$page = $this->pageService->getPageById($pageId);
197+
if ($page->getCustomLayoutUpdateXml() || $page->getLayoutUpdateXml()) {
198+
$options[] = ['label' => 'Use existing layout update XML', 'value' => '_existing_'];
199+
}
200+
foreach ($this->pageService->fetchAvailableCustomLayouts($page) as $layoutFile) {
201+
$options[] = ['label' => $layoutFile, 'value' => $layoutFile];
202+
}
224203
}
225204
} catch (LocalizedException $e) {
226205
$this->logger->error($e->getMessage());

0 commit comments

Comments
 (0)