Skip to content

Commit aaeadff

Browse files
authored
Merge pull request #6724 from magento-tsg-csl3/2.4-develop-pr55
[TSG-CSL3] For 2.4 (pr55)
2 parents 1b82d65 + db08be4 commit aaeadff

File tree

13 files changed

+604
-173
lines changed

13 files changed

+604
-173
lines changed

app/code/Magento/BundleImportExport/Model/Import/Product/Type/Bundle.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -573,8 +573,12 @@ protected function insertOptions()
573573

574574
$optionIds = $this->connection->fetchAssoc(
575575
$this->connection->select()->from(
576-
$this->_resource->getTableName('catalog_product_bundle_option'),
576+
['bo' => $this->_resource->getTableName('catalog_product_bundle_option')],
577577
['option_id', 'position', 'parent_id']
578+
)->joinLeft(
579+
['bov' => $this->_resource->getTableName('catalog_product_bundle_option_value')],
580+
'bo.option_id = bov.option_id',
581+
['title']
578582
)->where(
579583
'parent_id IN (?)',
580584
$productIds
@@ -600,8 +604,10 @@ protected function populateInsertOptionValues(array $optionIds): array
600604
foreach ($this->_cachedOptions as $entityId => $options) {
601605
foreach ($options as $key => $option) {
602606
foreach ($optionIds as $optionId => $assoc) {
603-
if ($assoc['position'] == $this->_cachedOptions[$entityId][$key]['index']
604-
&& $assoc['parent_id'] == $entityId) {
607+
if ($assoc['position'] == $this->_cachedOptions[$entityId][$key]['index'] &&
608+
$assoc['parent_id'] == $entityId &&
609+
(empty($assoc['title']) || $assoc['title'] == $this->_cachedOptions[$entityId][$key]['name'])
610+
) {
605611
$option['parent_id'] = $entityId;
606612
$optionValues[] = $this->populateOptionValueTemplate($option, $optionId);
607613
$this->_cachedOptions[$entityId][$key]['option_id'] = $optionId;

app/code/Magento/BundleImportExport/Test/Unit/Model/Import/Product/Type/BundleTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ public function testSaveData($skus, $bunch, $allowImport)
289289
'type' => 'bundle',
290290
'value_id' => '6',
291291
'title' => 'Bundle6',
292+
'name' => 'Bundle6',
292293
'selections' => [
293294
[
294295
'name' => 'Bundlen6',

app/code/Magento/CatalogGraphQl/Model/Resolver/Products/DataProvider/ExtractDataFromCategoryTree.php

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ public function execute(\Iterator $iterator): array
6767
$tree = $this->mergeCategoriesTrees($currentLevelTree, $tree);
6868
}
6969
}
70-
return $tree;
70+
71+
return $this->sortTree($tree);
7172
}
7273

7374
/**
@@ -141,4 +142,24 @@ private function explodePathToArray(array $pathElements, int $index): array
141142
}
142143
return $tree;
143144
}
145+
146+
/**
147+
* Recursive method to sort tree
148+
*
149+
* @param array $tree
150+
* @return array
151+
*/
152+
private function sortTree(array $tree): array
153+
{
154+
foreach ($tree as &$node) {
155+
if ($node['children']) {
156+
uasort($node['children'], function ($element1, $element2) {
157+
return $element1['position'] > $element2['position'];
158+
});
159+
$node['children'] = $this->sortTree($node['children']);
160+
}
161+
}
162+
163+
return $tree;
164+
}
144165
}

0 commit comments

Comments
 (0)