Skip to content

Commit e6f46fb

Browse files
Merge remote-tracking branch 'remotes/github/MAGETWO-72172' into EPAM-PR-68
2 parents 5875461 + aff63b3 commit e6f46fb

File tree

44 files changed

+1357
-293
lines changed

Some content is hidden

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

44 files changed

+1357
-293
lines changed

app/code/Magento/Backend/Block/Page/RequireJs.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ public function __construct(
2929
\Magento\Framework\Data\Form\FormKey $formKey,
3030
array $data = []
3131
) {
32-
$this->formKey = $formKey;
3332
parent::__construct(
3433
$context,
3534
$data
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Bundle\Setup\Patch\Schema;
9+
10+
use Magento\Framework\Setup\Patch\SchemaPatchInterface;
11+
use Magento\Framework\Setup\SchemaSetupInterface;
12+
13+
/**
14+
* Change engine for temporary tables to InnoDB.
15+
*/
16+
class ChangeTmpTablesEngine implements SchemaPatchInterface
17+
{
18+
/**
19+
* @var SchemaSetupInterface
20+
*/
21+
private $schemaSetup;
22+
23+
/**
24+
* @param SchemaSetupInterface $schemaSetup
25+
*/
26+
public function __construct(SchemaSetupInterface $schemaSetup)
27+
{
28+
$this->schemaSetup = $schemaSetup;
29+
}
30+
31+
/**
32+
* @inheritdoc
33+
*/
34+
public function apply()
35+
{
36+
$this->schemaSetup->startSetup();
37+
38+
$tables = [
39+
'catalog_product_index_price_bundle_tmp',
40+
'catalog_product_index_price_bundle_sel_tmp',
41+
'catalog_product_index_price_bundle_opt_tmp',
42+
];
43+
foreach ($tables as $table) {
44+
$this->schemaSetup->getConnection()->changeTableEngine($table, 'InnoDB');
45+
}
46+
47+
$this->schemaSetup->endSetup();
48+
}
49+
50+
/**
51+
* @inheritdoc
52+
*/
53+
public static function getDependencies()
54+
{
55+
return [];
56+
}
57+
58+
/**
59+
* @inheritdoc
60+
*/
61+
public function getAliases()
62+
{
63+
return [];
64+
}
65+
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Catalog\Setup\Patch\Schema;
9+
10+
use Magento\Framework\Setup\Patch\SchemaPatchInterface;
11+
use Magento\Framework\Setup\SchemaSetupInterface;
12+
13+
/**
14+
* Change engine for temporary tables to InnoDB.
15+
*/
16+
class ChangeTmpTablesEngine implements SchemaPatchInterface
17+
{
18+
/**
19+
* @var SchemaSetupInterface
20+
*/
21+
private $schemaSetup;
22+
23+
/**
24+
* @param SchemaSetupInterface $schemaSetup
25+
*/
26+
public function __construct(SchemaSetupInterface $schemaSetup)
27+
{
28+
$this->schemaSetup = $schemaSetup;
29+
}
30+
31+
/**
32+
* @inheritdoc
33+
*/
34+
public function apply()
35+
{
36+
$this->schemaSetup->startSetup();
37+
38+
$tables = [
39+
'catalog_product_index_price_cfg_opt_agr_tmp',
40+
'catalog_product_index_price_cfg_opt_tmp',
41+
'catalog_product_index_price_final_tmp',
42+
'catalog_product_index_price_opt_tmp',
43+
'catalog_product_index_price_opt_agr_tmp',
44+
'catalog_product_index_eav_tmp',
45+
'catalog_product_index_eav_decimal_tmp',
46+
'catalog_product_index_price_tmp',
47+
'catalog_category_product_index_tmp',
48+
];
49+
foreach ($tables as $table) {
50+
$this->schemaSetup->getConnection()->changeTableEngine($table, 'InnoDB');
51+
}
52+
53+
$this->schemaSetup->endSetup();
54+
}
55+
56+
/**
57+
* @inheritdoc
58+
*/
59+
public static function getDependencies()
60+
{
61+
return [];
62+
}
63+
64+
/**
65+
* @inheritdoc
66+
*/
67+
public function getAliases()
68+
{
69+
return [];
70+
}
71+
}

app/code/Magento/Catalog/Test/Mftf/Test/AdminSimpleSetEditRelatedProductsTest.xml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
2323
<createData entity="SimpleProduct2" stepKey="simpleProduct0"/>
2424
<createData entity="SimpleProduct2" stepKey="simpleProduct1"/>
25+
<createData entity="SimpleProduct2" stepKey="simpleProduct2"/>
26+
<createData entity="SimpleProduct2" stepKey="simpleProduct3"/>
27+
<createData entity="SimpleProduct2" stepKey="simpleProduct4"/>
28+
<createData entity="SimpleProduct2" stepKey="simpleProduct5"/>
29+
<createData entity="SimpleProduct2" stepKey="simpleProduct6"/>
2530
</before>
2631
<after>
2732
<!-- Delete simple product -->
@@ -31,6 +36,11 @@
3136
<amOnPage url="{{AdminLogoutPage.url}}" stepKey="amOnLogoutPage"/>
3237
<deleteData createDataKey="simpleProduct0" stepKey="deleteSimpleProduct0"/>
3338
<deleteData createDataKey="simpleProduct1" stepKey="deleteSimpleProduct1"/>
39+
<deleteData createDataKey="simpleProduct2" stepKey="deleteSimpleProduct2"/>
40+
<deleteData createDataKey="simpleProduct3" stepKey="deleteSimpleProduct3"/>
41+
<deleteData createDataKey="simpleProduct4" stepKey="deleteSimpleProduct4"/>
42+
<deleteData createDataKey="simpleProduct5" stepKey="deleteSimpleProduct5"/>
43+
<deleteData createDataKey="simpleProduct6" stepKey="deleteSimpleProduct6"/>
3444
</after>
3545

3646
<!--Create product-->
@@ -69,6 +79,28 @@
6979
<conditionalClick selector="{{AdminProductFormRelatedUpSellCrossSellSection.relatedDropdown}}" dependentSelector="{{AdminProductFormRelatedUpSellCrossSellSection.relatedDependent}}" visible="false" stepKey="openDropDownIfClosedRelatedSee"/>
7080
<see selector="{{AdminProductFormRelatedUpSellCrossSellSection.selectedRelatedProduct}}" userInput="$$simpleProduct1.sku$$" stepKey="seeRelatedProduct"/>
7181

82+
<!--See more related products in admin-->
83+
<actionGroup ref="addRelatedProductBySku" stepKey="addRelatedProduct2">
84+
<argument name="sku" value="$$simpleProduct2.sku$$"/>
85+
</actionGroup>
86+
<actionGroup ref="addRelatedProductBySku" stepKey="addRelatedProduct3">
87+
<argument name="sku" value="$$simpleProduct3.sku$$"/>
88+
</actionGroup>
89+
<actionGroup ref="addRelatedProductBySku" stepKey="addRelatedProduct4">
90+
<argument name="sku" value="$$simpleProduct4.sku$$"/>
91+
</actionGroup>
92+
<actionGroup ref="addRelatedProductBySku" stepKey="addRelatedProduct5">
93+
<argument name="sku" value="$$simpleProduct5.sku$$"/>
94+
</actionGroup>
95+
<actionGroup ref="addRelatedProductBySku" stepKey="addRelatedProduct6">
96+
<argument name="sku" value="$$simpleProduct6.sku$$"/>
97+
</actionGroup>
98+
<scrollTo selector="{{AdminProductFormRelatedUpSellCrossSellSection.relatedDropdown}}" stepKey="scrollTo2"/>
99+
<conditionalClick selector="{{AdminProductFormRelatedUpSellCrossSellSection.relatedDropdown}}" dependentSelector="{{AdminProductFormRelatedUpSellCrossSellSection.relatedDependent}}" visible="false" stepKey="openDropDownIfClosedRelatedSee2"/>
100+
<see selector="{{AdminProductFormRelatedUpSellCrossSellSection.selectedRelatedProduct}}" userInput="$$simpleProduct6.sku$$" stepKey="seeSixthRelatedProduct"/>
101+
<selectOption selector=".admin__collapsible-block-wrapper[data-index='related'] .admin__control-select" userInput="5" stepKey="selectFivePerPage"/>
102+
<dontSee selector="{{AdminProductFormRelatedUpSellCrossSellSection.selectedRelatedProduct}}" userInput="$$simpleProduct6.sku$$" stepKey="dontSeeSixthRelatedProduct"/>
103+
72104
<!--See related product in storefront-->
73105
<amOnPage url="{{SimpleProduct3.sku}}.html" stepKey="goToStorefront"/>
74106
<waitForPageLoad stepKey="waitForStorefront"/>

app/code/Magento/CatalogGraphQl/Model/Resolver/Categories.php

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

88
namespace Magento\CatalogGraphQl\Model\Resolver;
99

10+
use Magento\CatalogGraphQl\Model\Resolver\Product\ProductCategories;
1011
use Magento\Framework\Exception\LocalizedException;
1112
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
1213
use Magento\Catalog\Api\Data\CategoryInterface;
@@ -18,6 +19,7 @@
1819
use Magento\Framework\GraphQl\Query\ResolverInterface;
1920
use Magento\Framework\GraphQl\Query\Resolver\ValueFactory;
2021
use Magento\CatalogGraphQl\Model\Category\Hydrator as CategoryHydrator;
22+
use Magento\Store\Model\StoreManagerInterface;
2123

2224
/**
2325
* Resolver for category objects the product is assigned to.
@@ -56,25 +58,41 @@ class Categories implements ResolverInterface
5658
*/
5759
private $categoryHydrator;
5860

61+
/**
62+
* @var ProductCategories
63+
*/
64+
private $productCategories;
65+
66+
/**
67+
* @var StoreManagerInterface
68+
*/
69+
private $storeManager;
70+
5971
/**
6072
* @param CollectionFactory $collectionFactory
6173
* @param AttributesJoiner $attributesJoiner
6274
* @param CustomAttributesFlattener $customAttributesFlattener
6375
* @param ValueFactory $valueFactory
6476
* @param CategoryHydrator $categoryHydrator
77+
* @param ProductCategories $productCategories
78+
* @param StoreManagerInterface $storeManager
6579
*/
6680
public function __construct(
6781
CollectionFactory $collectionFactory,
6882
AttributesJoiner $attributesJoiner,
6983
CustomAttributesFlattener $customAttributesFlattener,
7084
ValueFactory $valueFactory,
71-
CategoryHydrator $categoryHydrator
85+
CategoryHydrator $categoryHydrator,
86+
ProductCategories $productCategories,
87+
StoreManagerInterface $storeManager
7288
) {
7389
$this->collection = $collectionFactory->create();
7490
$this->attributesJoiner = $attributesJoiner;
7591
$this->customAttributesFlattener = $customAttributesFlattener;
7692
$this->valueFactory = $valueFactory;
7793
$this->categoryHydrator = $categoryHydrator;
94+
$this->productCategories = $productCategories;
95+
$this->storeManager = $storeManager;
7896
}
7997

8098
/**
@@ -90,39 +108,42 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value
90108

91109
/** @var \Magento\Catalog\Model\Product $product */
92110
$product = $value['model'];
93-
$categoryIds = $product->getCategoryIds();
111+
$storeId = $this->storeManager->getStore()->getId();
112+
$categoryIds = $this->productCategories->getCategoryIdsByProduct((int)$product->getId(), (int)$storeId);
94113
$this->categoryIds = array_merge($this->categoryIds, $categoryIds);
95114
$that = $this;
96115

97-
return $this->valueFactory->create(function () use ($that, $categoryIds, $info) {
98-
$categories = [];
99-
if (empty($that->categoryIds)) {
100-
return [];
101-
}
116+
return $this->valueFactory->create(
117+
function () use ($that, $categoryIds, $info) {
118+
$categories = [];
119+
if (empty($that->categoryIds)) {
120+
return [];
121+
}
102122

103-
if (!$this->collection->isLoaded()) {
104-
$that->attributesJoiner->join($info->fieldNodes[0], $this->collection);
105-
$this->collection->addIdFilter($this->categoryIds);
106-
}
107-
/** @var CategoryInterface | \Magento\Catalog\Model\Category $item */
108-
foreach ($this->collection as $item) {
109-
if (in_array($item->getId(), $categoryIds)) {
110-
// Try to extract all requested fields from the loaded collection data
111-
$categories[$item->getId()] = $this->categoryHydrator->hydrateCategory($item, true);
112-
$categories[$item->getId()]['model'] = $item;
113-
$requestedFields = $that->attributesJoiner->getQueryFields($info->fieldNodes[0]);
114-
$extractedFields = array_keys($categories[$item->getId()]);
115-
$foundFields = array_intersect($requestedFields, $extractedFields);
116-
if (count($requestedFields) === count($foundFields)) {
117-
continue;
118-
}
123+
if (!$this->collection->isLoaded()) {
124+
$that->attributesJoiner->join($info->fieldNodes[0], $this->collection);
125+
$this->collection->addIdFilter($this->categoryIds);
126+
}
127+
/** @var CategoryInterface | \Magento\Catalog\Model\Category $item */
128+
foreach ($this->collection as $item) {
129+
if (in_array($item->getId(), $categoryIds)) {
130+
// Try to extract all requested fields from the loaded collection data
131+
$categories[$item->getId()] = $this->categoryHydrator->hydrateCategory($item, true);
132+
$categories[$item->getId()]['model'] = $item;
133+
$requestedFields = $that->attributesJoiner->getQueryFields($info->fieldNodes[0]);
134+
$extractedFields = array_keys($categories[$item->getId()]);
135+
$foundFields = array_intersect($requestedFields, $extractedFields);
136+
if (count($requestedFields) === count($foundFields)) {
137+
continue;
138+
}
119139

120-
// If not all requested fields were extracted from the collection, start more complex extraction
121-
$categories[$item->getId()] = $this->categoryHydrator->hydrateCategory($item);
140+
// If not all requested fields were extracted from the collection, start more complex extraction
141+
$categories[$item->getId()] = $this->categoryHydrator->hydrateCategory($item);
142+
}
122143
}
123-
}
124144

125-
return $categories;
126-
});
145+
return $categories;
146+
}
147+
);
127148
}
128149
}

0 commit comments

Comments
 (0)