Skip to content

Commit 054c4d8

Browse files
Merge branch '2.4-develop' into fix-for-issue-37873
2 parents 246cfcd + 2f5faa7 commit 054c4d8

File tree

83 files changed

+2372
-1297
lines changed

Some content is hidden

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

83 files changed

+2372
-1297
lines changed

app/code/Magento/Bundle/Test/Mftf/Section/StorefrontProductInfoMainSection.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<element name="minPrice" type="text" selector="span[data-price-type='minPrice']"/>
1515
<element name="maxPrice" type="text" selector="span[data-price-type='minPrice']"/>
1616
<element name="asLowAsFinalPrice" type="text" selector="div.price-box.price-final_price p.minimal-price > span.price-final_price span.price"/>
17-
<element name="fixedFinalPrice" type="text" selector="div.price-box.price-final_price > span.price-final_price span.price"/>
17+
<element name="fixedFinalPrice" type="text" selector="div.price-box.price-final_price p.price-from span.price-final_price span.price-wrapper span.price"/>
1818
<element name="productBundleOptionsCheckbox" type="checkbox" selector="//*[@id='product-options-wrapper']//div[@class='fieldset']//label[contains(.,'{{childName}}')]/../input" parameterized="true" timeout="30"/>
1919
<element name="productBundleOneOptionInput" type="input" selector="//*[@id='product-options-wrapper']//div[@class='fieldset']//label[contains(.,'{{childName}}')]/..//input[contains(@class, 'option')]" parameterized="true" timeout="30"/>
2020
<element name="productBundleOptionQty" type="input" selector="//*[@id='product-options-wrapper']//div[@class='fieldset']//label[contains(.,'{{childName}}')]/..//input[contains(@class, 'qty')]" parameterized="true" timeout="30"/>

app/code/Magento/Catalog/Helper/Product/View.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ private function preparePageMetadata(ResultPage $resultPage, $product)
118118
$pageConfig = $resultPage->getConfig();
119119

120120
$metaTitle = $product->getMetaTitle();
121-
$pageConfig->setMetaTitle($metaTitle);
121+
$productMetaTitle = $metaTitle ? $this->addConfigValues($metaTitle) : null;
122+
$pageConfig->setMetaTitle($productMetaTitle);
122123
$pageConfig->getTitle()->set($metaTitle ?: $product->getName());
123124

124125
$keyword = $product->getMetaKeyword();
@@ -294,4 +295,22 @@ public function prepareAndRender(ResultPage $resultPage, $productId, $controller
294295
$this->preparePageMetadata($resultPage, $product);
295296
return $this;
296297
}
298+
299+
/**
300+
* Add Prefix and Suffix as per the configuration.
301+
*
302+
* @param string $title
303+
* @return string
304+
*/
305+
private function addConfigValues(string $title): string
306+
{
307+
$preparedTitle = $this->scopeConfig->getValue(
308+
'design/head/title_prefix',
309+
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
310+
) . ' ' . $title . ' ' . $this->scopeConfig->getValue(
311+
'design/head/title_suffix',
312+
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
313+
);
314+
return trim($preparedTitle);
315+
}
297316
}

app/code/Magento/Catalog/Model/Indexer/Product/Price/Action/Full.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,15 +311,14 @@ private function reindexByBatchWithDimensions(
311311
if (!empty($entityIds)) {
312312
$this->dimensionTableMaintainer->createMainTmpTable($dimensions);
313313
$temporaryTable = $this->dimensionTableMaintainer->getMainTmpTable($dimensions);
314-
$this->_emptyTable($temporaryTable);
315-
316314
$priceIndexer->executeByDimensions($dimensions, \SplFixedArray::fromArray($entityIds, false));
317315

318316
// Sync data from temp table to index table
319317
$this->_insertFromTable(
320318
$temporaryTable,
321319
$this->dimensionTableMaintainer->getMainReplicaTable($dimensions)
322320
);
321+
$this->_defaultIndexerResource->getConnection()->dropTable($temporaryTable);
323322
}
324323
}
325324

@@ -354,7 +353,6 @@ private function reindexBatch(PriceInterface $priceIndexer, Select $batch): void
354353
if (!empty($entityIds)) {
355354
// Temporary table will created if not exists
356355
$idxTableName = $this->_defaultIndexerResource->getIdxTable();
357-
$this->_emptyTable($idxTableName);
358356

359357
if ($priceIndexer->getIsComposite()) {
360358
$this->_copyRelationIndexData($entityIds);
@@ -489,6 +487,7 @@ private function moveDataFromReplicaTableToReplicaTables(array $dimensions): voi
489487
* Retrieves the index table that should be used
490488
*
491489
* @deprecated 102.0.6
490+
* @see only used in another deprecated method: _copyRelationIndexData
492491
*/
493492
protected function getIndexTargetTable(): string
494493
{

app/code/Magento/Catalog/Model/ProductRepository.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,6 @@ class ProductRepository implements \Magento\Catalog\Api\ProductRepositoryInterfa
6666
*/
6767
protected $instancesById = [];
6868

69-
/**
70-
* @var \Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper
71-
*/
72-
protected $initializationHelper;
73-
7469
/**
7570
* @var \Magento\Catalog\Api\Data\ProductSearchResultsInterfaceFactory
7671
*/
@@ -195,7 +190,6 @@ class ProductRepository implements \Magento\Catalog\Api\ProductRepositoryInterfa
195190
/**
196191
* ProductRepository constructor.
197192
* @param ProductFactory $productFactory
198-
* @param \Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper $initializationHelper
199193
* @param \Magento\Catalog\Api\Data\ProductSearchResultsInterfaceFactory $searchResultsFactory
200194
* @param ResourceModel\Product\CollectionFactory $collectionFactory
201195
* @param \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder
@@ -225,7 +219,6 @@ class ProductRepository implements \Magento\Catalog\Api\ProductRepositoryInterfa
225219
*/
226220
public function __construct(
227221
ProductFactory $productFactory,
228-
\Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper $initializationHelper,
229222
\Magento\Catalog\Api\Data\ProductSearchResultsInterfaceFactory $searchResultsFactory,
230223
\Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $collectionFactory,
231224
\Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder,
@@ -253,7 +246,6 @@ public function __construct(
253246
) {
254247
$this->productFactory = $productFactory;
255248
$this->collectionFactory = $collectionFactory;
256-
$this->initializationHelper = $initializationHelper;
257249
$this->searchResultsFactory = $searchResultsFactory;
258250
$this->searchCriteriaBuilder = $searchCriteriaBuilder;
259251
$this->resourceModel = $resourceModel;
@@ -940,7 +932,7 @@ private function joinPositionField(
940932
foreach ($filterGroup->getFilters() as $filter) {
941933
if ($filter->getField() === 'category_id') {
942934
$filterValue = $filter->getValue();
943-
$categoryIds[] = is_array($filterValue) ? $filterValue : explode(',', $filterValue ?? '');
935+
$categoryIds[] = is_array($filterValue) ? $filterValue : explode(',', $filterValue);
944936
}
945937
}
946938
}

app/code/Magento/Catalog/Model/ProductRepository/MediaGalleryProcessor.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ public function __construct(
8282
* @throws InputException
8383
* @throws StateException
8484
* @throws LocalizedException
85+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
8586
*/
8687
public function processMediaGallery(ProductInterface $product, array $mediaGalleryEntries) :void
8788
{
@@ -113,6 +114,9 @@ public function processMediaGallery(ProductInterface $product, array $mediaGalle
113114
// phpcs:ignore Magento2.Performance.ForeachArrayMerge
114115
$existingMediaGallery[$key] = array_merge($existingEntry, $updatedEntry);
115116
}
117+
} elseif (!empty($newEntries) && isset($existingEntry['value_id'])) {
118+
//avoid deleting an exiting image while adding a new one
119+
unset($existingMediaGallery[$key]);
116120
} elseif ($this->canRemoveImage($product, $existingEntry)) {
117121
//set the removed flag
118122
$existingEntry['removed'] = true;

app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/CustomOptionPriceModifier.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ public function modifyPrice(IndexTableStructure $priceTable, array $entityIds =
122122
$query = $select->crossUpdateFromSelect(['i' => $finalPriceTable]);
123123
$connection->query($query);
124124

125-
$connection->delete($coaTable);
126-
$connection->delete($copTable);
125+
$connection->dropTemporaryTable($coaTable);
126+
$connection->dropTemporaryTable($copTable);
127127
}
128128

129129
/**

app/code/Magento/Catalog/Test/Fixture/Attribute.php

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
namespace Magento\Catalog\Test\Fixture;
99

10-
use Magento\Catalog\Api\Data\ProductAttributeInterface;
1110
use Magento\Catalog\Api\ProductAttributeManagementInterface;
1211
use Magento\Catalog\Api\ProductAttributeRepositoryInterface;
1312
use Magento\Catalog\Model\Product;
@@ -96,6 +95,11 @@ class Attribute implements RevertibleDataFixtureInterface
9695
*/
9796
private ResourceModelAttribute $resourceModelAttribute;
9897

98+
/**
99+
* @var ProductAttributeRepositoryInterface
100+
*/
101+
private ProductAttributeRepositoryInterface $productAttributeRepository;
102+
99103
/**
100104
* @param ServiceFactory $serviceFactory
101105
* @param ProcessorInterface $dataProcessor
@@ -104,6 +108,7 @@ class Attribute implements RevertibleDataFixtureInterface
104108
* @param AttributeFactory $attributeFactory
105109
* @param DataMerger $dataMerger
106110
* @param ResourceModelAttribute $resourceModelAttribute
111+
* @param ProductAttributeRepositoryInterface $productAttributeRepository
107112
*/
108113
public function __construct(
109114
ServiceFactory $serviceFactory,
@@ -112,7 +117,8 @@ public function __construct(
112117
ProductAttributeManagementInterface $productAttributeManagement,
113118
AttributeFactory $attributeFactory,
114119
DataMerger $dataMerger,
115-
ResourceModelAttribute $resourceModelAttribute
120+
ResourceModelAttribute $resourceModelAttribute,
121+
ProductAttributeRepositoryInterface $productAttributeRepository
116122
) {
117123
$this->serviceFactory = $serviceFactory;
118124
$this->dataProcessor = $dataProcessor;
@@ -121,6 +127,7 @@ public function __construct(
121127
$this->attributeFactory = $attributeFactory;
122128
$this->dataMerger = $dataMerger;
123129
$this->resourceModelAttribute = $resourceModelAttribute;
130+
$this->productAttributeRepository = $productAttributeRepository;
124131
}
125132

126133
/**
@@ -134,16 +141,11 @@ public function apply(array $data = []): ?DataObject
134141
return $this->applyAttributeWithAdditionalData($data);
135142
}
136143

137-
$service = $this->serviceFactory->create(ProductAttributeRepositoryInterface::class, 'save');
138-
139-
/**
140-
* @var ProductAttributeInterface $attribute
141-
*/
142-
$attribute = $service->execute(
143-
[
144-
'attribute' => $this->prepareData(array_diff_key($data, self::DEFAULT_ATTRIBUTE_SET_DATA))
145-
]
144+
$attribute = $this->attributeFactory->createAttribute(
145+
EavAttribute::class,
146+
$this->prepareData(array_diff_key($data, self::DEFAULT_ATTRIBUTE_SET_DATA))
146147
);
148+
$attribute = $this->productAttributeRepository->save($attribute);
147149

148150
$attributeSetData = $this->prepareAttributeSetData(
149151
array_intersect_key($data, self::DEFAULT_ATTRIBUTE_SET_DATA)
@@ -201,6 +203,7 @@ private function applyAttributeWithAdditionalData(array $data = []): ?DataObject
201203
private function prepareData(array $data): array
202204
{
203205
$data = array_merge(self::DEFAULT_DATA, $data);
206+
$data['frontend_label'] ??= $data['default_frontend_label'];
204207

205208
return $this->dataProcessor->process($this, $data);
206209
}

app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertProductImageStorefrontProductPageActionGroup.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
<seeInCurrentUrl url="/{{product.urlKey}}.html" stepKey="checkUrl"/>
2121
<waitForPageLoad stepKey="waitForPageLoad"/>
22-
<waitForElement selector="{{StorefrontProductMediaSection.imageFile(image.filename)}}" stepKey="waitForImage"/>
23-
<seeElement selector="{{StorefrontProductMediaSection.imageFile(image.filename)}}" stepKey="seeImage"/>
22+
<waitForElement selector="{{StorefrontProductMediaSection.imageFileInGallery(image.filename)}}" stepKey="waitForImage"/>
23+
<seeElement selector="{{StorefrontProductMediaSection.imageFileInGallery(image.filename)}}" stepKey="seeImage"/>
2424
</actionGroup>
2525
</actionGroups>

app/code/Magento/Catalog/Test/Mftf/Section/StorefrontProductInfoMainSection.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
<element name="oldPriceTag" type="text" selector=".old-price .price-label"/>
2525
<element name="oldPriceAmount" type="text" selector=".old-price span.price"/>
2626
<element name="productStockStatus" type="text" selector=".stock[title=Availability]>span"/>
27-
<element name="productImage" type="text" selector="//*[@id='maincontent']//div[@class='gallery-placeholder']//img[@class='fotorama__img']"/>
28-
<element name="productImageSrc" type="text" selector="//*[@id='maincontent']//div[@class='gallery-placeholder']//img[contains(@src, '{{src}}')]" parameterized="true"/>
27+
<element name="productImage" type="text" selector="//*[@id='maincontent']//div[@class='gallery-placeholder']//img[contains(@class, 'fotorama__img')]"/>
28+
<element name="productImageSrc" type="text" selector="//*[@id='maincontent']//div[@class='gallery-placeholder']//img[contains(@class, 'fotorama__img')][contains(@src, '{{src}}')]" parameterized="true"/>
2929
<element name="productDescription" type="text" selector="#description .value"/>
3030
<element name="productOptionFieldInput" type="input" selector="//*[@id='product-options-wrapper']//div[@class='fieldset']//label[contains(.,'{{var1}}')]/../div[@class='control']//input[@type='text']" parameterized="true"/>
3131
<element name="productOptionAreaInput" type="textarea" selector="//*[@id='product-options-wrapper']//div[@class='fieldset']//label[contains(.,'{{var1}}')]/../div[@class='control']//textarea" parameterized="true"/>

app/code/Magento/Catalog/Test/Mftf/Section/StorefrontProductMediaSection.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
<element name="productImage" type="text" selector="//*[@data-gallery-role='gallery' and not(contains(@class, 'fullscreen'))]//img[contains(@src, '{{filename}}') and not(contains(@class, 'full'))]" parameterized="true" />
1616
<element name="productImageFullscreen" type="text" selector="//*[@data-gallery-role='gallery' and contains(@class, 'fullscreen')]//img[contains(@src, '{{filename}}') and contains(@class, 'full')]" parameterized="true" />
1717
<element name="closeFullscreenImage" type="button" selector="//*[@data-gallery-role='gallery' and contains(@class, 'fullscreen')]//*[@data-gallery-role='fotorama__fullscreen-icon']" />
18-
<element name="imageFile" type="text" selector="//*[@class='product media']//img[contains(@src, '{{filename}}')]" parameterized="true"/>
18+
<element name="imageFile" type="text" selector="//div[contains(@class, 'fotorama__active')]//img[contains(@src, '{{filename}}')]" parameterized="true"/>
19+
<element name="imageFileInGallery" type="text" selector="//div[contains(@class, 'fotorama__loaded--img')]//img[contains(@src, '{{filename}}')]" parameterized="true"/>
1920
<element name="productImageActive" type="text" selector=".product.media div[data-active=true] > img[src*='{{filename}}']" parameterized="true"/>
2021
<element name="productImageInFotorama" type="file" selector=".fotorama__nav__shaft img[src*='{{imageName}}']" parameterized="true" timeout="30"/>
2122
<element name="fotoramaPrevButton" type="button" selector="//*[@data-gallery-role='gallery']//*[@data-gallery-role='nav-wrap']//*[@data-gallery-role='arrow' and contains(@class, 'fotorama__thumb__arr--left')]" timeout="30"/>

0 commit comments

Comments
 (0)