Skip to content

Commit 9cfff6e

Browse files
authored
Merge branch '2.4-develop' into ui-file-uploader-failure-callback
2 parents 9d99f32 + edfbc39 commit 9cfff6e

20 files changed

+309
-231
lines changed

app/code/Magento/CatalogGraphQl/DataProvider/Product/LayeredNavigation/AttributeOptionProvider.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,13 @@ public function getOptions(array $optionIds, ?int $storeId, array $attributeCode
6464
'attribute_label' => 'a.frontend_label',
6565
]
6666
)
67+
->joinLeft(
68+
['attribute_label' => $this->resourceConnection->getTableName('eav_attribute_label')],
69+
"a.attribute_id = attribute_label.attribute_id AND attribute_label.store_id = {$storeId}",
70+
[
71+
'attribute_store_label' => 'attribute_label.value',
72+
]
73+
)
6774
->joinLeft(
6875
['options' => $this->resourceConnection->getTableName('eav_attribute_option')],
6976
'a.attribute_id = options.attribute_id',
@@ -119,7 +126,8 @@ private function formatResult(\Magento\Framework\DB\Select $select): array
119126
$result[$option['attribute_code']] = [
120127
'attribute_id' => $option['attribute_id'],
121128
'attribute_code' => $option['attribute_code'],
122-
'attribute_label' => $option['attribute_label'],
129+
'attribute_label' => $option['attribute_store_label']
130+
? $option['attribute_store_label'] : $option['attribute_label'],
123131
'options' => [],
124132
];
125133
}

app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerAddressGridMainActionsSection.xml

Lines changed: 0 additions & 15 deletions
This file was deleted.

app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerGridMainActionsSection.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313
<element name="multicheck" type="checkbox" selector="#container>div>div.admin__data-grid-wrap>table>thead>tr>th.data-grid-multicheck-cell>div>label"/>
1414
<element name="multicheckTick" type="checkbox" selector="#container>div>div.admin__data-grid-wrap>table>thead>tr>th.data-grid-multicheck-cell>div>input"/>
1515
<element name="delete" type="button" selector="//*[contains(@class, 'admin__data-grid-header')]//span[contains(@class,'action-menu-item') and text()='Delete']"/>
16-
<element name="actions" type="text" selector=".action-select"/>
1716
<element name="customerCheckbox" type="button" selector="//*[contains(text(),'{{arg}}')]/parent::td/preceding-sibling::td/label[@class='data-grid-checkbox-cell-inner']//input" parameterized="true"/>
1817
<element name="ok" type="button" selector="//button[@data-role='action']//span[text()='OK']"/>
18+
<element name="addNewAddress" type="button" selector=".add-new-address-button" timeout="30"/>
19+
<element name="actions" type="text" selector=".admin__data-grid-header-row .action-select"/>
1920
</section>
2021
</sections>

app/code/Magento/User/Test/Mftf/Section/AdminDeleteRoleSection.xml

Lines changed: 0 additions & 20 deletions
This file was deleted.

app/code/Magento/User/Test/Mftf/Section/AdminDeleteUserSection.xml

Lines changed: 0 additions & 17 deletions
This file was deleted.

app/code/Magento/User/Test/Mftf/Section/AdminRoleGridSection/AdminDeleteRoleSection.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
1010
<section name="AdminDeleteRoleSection">
1111
<element name="theRole" selector="//td[contains(text(), 'Role')]" type="button"/>
12-
<element name="role" parameterized="true" selector="//td[contains(text(), '{{args}}')]" type="button"/>
12+
<element name="salesRole" selector="//td[contains(text(), 'Sales')]" type="button"/>
13+
<element name="role" parameterized="true" selector="//td[contains(@class,'col-role_name') and contains(text(), '{{roleName}}')]" type="button"/>
1314
<element name="current_pass" type="button" selector="#current_password"/>
1415
<element name="delete" selector="//button/span[contains(text(), 'Delete Role')]" type="button"/>
1516
<element name="confirm" selector="//*[@class='action-primary action-accept']" type="button"/>

app/code/Magento/User/Test/Mftf/Section/AdminUserGridSection/AdminDeleteUserSection.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<element name="theUser" selector="//td[contains(text(), '{{userName}}')]" type="button" parameterized="true"/>
1212
<element name="password" selector="#user_current_password" type="input"/>
1313
<element name="delete" selector="//button/span[contains(text(), 'Delete User')]" type="button"/>
14-
<element name="confirm" selector="//*[@class='action-primary action-accept']" type="button"/>
14+
<element name="confirm" selector=".action-primary.action-accept" type="button"/>
1515
<element name="role" parameterized="true" selector="//td[contains(text(), '{{args}}')]" type="button"/>
1616
</section>
1717
</sections>

app/code/Magento/Wishlist/Model/Wishlist/RemoveProductsFromWishlist.php

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

88
namespace Magento\Wishlist\Model\Wishlist;
99

10+
use Magento\Framework\Exception\LocalizedException;
1011
use Magento\Wishlist\Model\Item as WishlistItem;
1112
use Magento\Wishlist\Model\ItemFactory as WishlistItemFactory;
1213
use Magento\Wishlist\Model\ResourceModel\Item as WishlistItemResource;
@@ -63,7 +64,7 @@ public function __construct(
6364
public function execute(Wishlist $wishlist, array $wishlistItemsIds): WishlistOutput
6465
{
6566
foreach ($wishlistItemsIds as $wishlistItemId) {
66-
$this->removeItemFromWishlist((int) $wishlistItemId);
67+
$this->removeItemFromWishlist((int) $wishlistItemId, $wishlist);
6768
}
6869

6970
return $this->prepareOutput($wishlist);
@@ -73,12 +74,22 @@ public function execute(Wishlist $wishlist, array $wishlistItemsIds): WishlistOu
7374
* Remove product item from wishlist
7475
*
7576
* @param int $wishlistItemId
77+
* @param Wishlist $wishlist
7678
*
7779
* @return void
7880
*/
79-
private function removeItemFromWishlist(int $wishlistItemId): void
81+
private function removeItemFromWishlist(int $wishlistItemId, Wishlist $wishlist): void
8082
{
8183
try {
84+
if ($wishlist->getItem($wishlistItemId) == null) {
85+
throw new LocalizedException(
86+
__(
87+
'The wishlist item with ID "%id" does not belong to the wishlist',
88+
['id' => $wishlistItemId]
89+
)
90+
);
91+
}
92+
$wishlist->getItemCollection()->clear();
8293
/** @var WishlistItem $wishlistItem */
8394
$wishlistItem = $this->wishlistItemFactory->create();
8495
$this->wishlistItemResource->load($wishlistItem, $wishlistItemId);
@@ -90,6 +101,8 @@ private function removeItemFromWishlist(int $wishlistItemId): void
90101
}
91102

92103
$this->wishlistItemResource->delete($wishlistItem);
104+
} catch (LocalizedException $exception) {
105+
$this->addError($exception->getMessage());
93106
} catch (\Exception $e) {
94107
$this->addError(
95108
__(

app/code/Magento/Wishlist/Model/Wishlist/UpdateProductsInWishlist.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,15 @@ public function execute(Wishlist $wishlist, array $wishlistItems): WishlistOutpu
9090
private function updateItemInWishlist(Wishlist $wishlist, WishlistItemData $wishlistItemData): void
9191
{
9292
try {
93+
if ($wishlist->getItem($wishlistItemData->getId()) == null) {
94+
throw new LocalizedException(
95+
__(
96+
'The wishlist item with ID "%id" does not belong to the wishlist',
97+
['id' => $wishlistItemData->getId()]
98+
)
99+
);
100+
}
101+
$wishlist->getItemCollection()->clear();
93102
$options = $this->buyRequestBuilder->build($wishlistItemData);
94103
/** @var WishlistItem $wishlistItem */
95104
$wishlistItem = $this->wishlistItemFactory->create();

composer.lock

Lines changed: 11 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/CategoriesQuery/CategoryTreeTest.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@
1111
use Magento\Catalog\Api\ProductRepositoryInterface;
1212
use Magento\Catalog\Model\CategoryRepository;
1313
use Magento\Catalog\Model\ResourceModel\Category\Collection as CategoryCollection;
14+
use Magento\Framework\App\ResourceConnection;
1415
use Magento\Framework\EntityManager\MetadataPool;
1516
use Magento\Store\Model\Store;
1617
use Magento\Store\Model\StoreManagerInterface;
18+
use Magento\TestFramework\Helper\Bootstrap;
1719
use Magento\TestFramework\ObjectManager;
1820
use Magento\TestFramework\TestCase\GraphQlAbstract;
1921

@@ -564,10 +566,12 @@ public function testCategoryImage(?string $imagePrefix)
564566
->addAttributeToFilter('name', ['eq' => 'Parent Image Category'])
565567
->getFirstItem();
566568
$categoryId = $categoryModel->getId();
569+
/** @var ResourceConnection $resourceConnection */
570+
$resourceConnection = Bootstrap::getObjectManager()->create(ResourceConnection::class);
571+
$connection = $resourceConnection->getConnection();
567572

568573
if ($imagePrefix !== null) {
569574
// update image to account for different stored image formats
570-
$connection = $categoryCollection->getConnection();
571575
$productLinkField = $this->metadataPool
572576
->getMetadata(\Magento\Catalog\Api\Data\ProductInterface::class)
573577
->getLinkField();
@@ -577,20 +581,20 @@ public function testCategoryImage(?string $imagePrefix)
577581
$imageAttributeValue = $imagePrefix . basename($categoryModel->getImage());
578582

579583
if (!empty($imageAttributeValue)) {
580-
$query = sprintf(
584+
$sqlQuery = sprintf(
581585
'UPDATE %s SET `value` = "%s" ' .
582586
'WHERE `%s` = %d ' .
583587
'AND `store_id`= %d ' .
584588
'AND `attribute_id` = ' .
585589
'(SELECT `ea`.`attribute_id` FROM %s ea WHERE `ea`.`attribute_code` = "image" LIMIT 1)',
586-
$connection->getTableName('catalog_category_entity_varchar'),
590+
$resourceConnection->getTableName('catalog_category_entity_varchar'),
587591
$imageAttributeValue,
588592
$productLinkField,
589593
$categoryModel->getData($productLinkField),
590594
$defaultStoreId,
591-
$connection->getTableName('eav_attribute')
595+
$resourceConnection->getTableName('eav_attribute')
592596
);
593-
$connection->query($query);
597+
$connection->query($sqlQuery);
594598
}
595599
}
596600

dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/CategoryTest.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,20 @@
1212
use Magento\Catalog\Api\ProductRepositoryInterface;
1313
use Magento\Catalog\Model\CategoryRepository;
1414
use Magento\Catalog\Model\ResourceModel\Category\Collection as CategoryCollection;
15+
use Magento\Framework\App\ResourceConnection;
1516
use Magento\Framework\DataObject;
1617
use Magento\Framework\EntityManager\MetadataPool;
1718
use Magento\Store\Model\Store;
1819
use Magento\Store\Model\StoreManagerInterface;
20+
use Magento\TestFramework\Helper\Bootstrap;
1921
use Magento\TestFramework\ObjectManager;
2022
use Magento\TestFramework\TestCase\GraphQl\ResponseContainsErrorsException;
2123
use Magento\TestFramework\TestCase\GraphQlAbstract;
2224

2325
/**
2426
* Test loading of category tree
27+
*
28+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2529
*/
2630
class CategoryTest extends GraphQlAbstract
2731
{
@@ -47,7 +51,7 @@ class CategoryTest extends GraphQlAbstract
4751

4852
protected function setUp(): void
4953
{
50-
$this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
54+
$this->objectManager = Bootstrap::getObjectManager();
5155
$this->categoryRepository = $this->objectManager->get(CategoryRepository::class);
5256
$this->store = $this->objectManager->get(Store::class);
5357
$this->metadataPool = $this->objectManager->get(MetadataPool::class);
@@ -587,9 +591,12 @@ public function testCategoryImage(?string $imagePrefix)
587591
->getFirstItem();
588592
$categoryId = $categoryModel->getId();
589593

594+
/** @var ResourceConnection $resourceConnection */
595+
$resourceConnection = Bootstrap::getObjectManager()->create(ResourceConnection::class);
596+
$connection = $resourceConnection->getConnection();
597+
590598
if ($imagePrefix !== null) {
591-
// update image to account for different stored image formats
592-
$connection = $categoryCollection->getConnection();
599+
// update image to account for different stored image format
593600
$productLinkField = $this->metadataPool
594601
->getMetadata(\Magento\Catalog\Api\Data\ProductInterface::class)
595602
->getLinkField();
@@ -599,20 +606,20 @@ public function testCategoryImage(?string $imagePrefix)
599606
$imageAttributeValue = $imagePrefix . basename($categoryModel->getImage());
600607

601608
if (!empty($imageAttributeValue)) {
602-
$query = sprintf(
609+
$sqlQuery = sprintf(
603610
'UPDATE %s SET `value` = "%s" ' .
604611
'WHERE `%s` = %d ' .
605612
'AND `store_id`= %d ' .
606613
'AND `attribute_id` = ' .
607614
'(SELECT `ea`.`attribute_id` FROM %s ea WHERE `ea`.`attribute_code` = "image" LIMIT 1)',
608-
$connection->getTableName('catalog_category_entity_varchar'),
615+
$resourceConnection->getTableName('catalog_category_entity_varchar'),
609616
$imageAttributeValue,
610617
$productLinkField,
611618
$categoryModel->getData($productLinkField),
612619
$defaultStoreId,
613-
$connection->getTableName('eav_attribute')
620+
$resourceConnection->getTableName('eav_attribute')
614621
);
615-
$connection->query($query);
622+
$connection->query($sqlQuery);
616623
}
617624
}
618625

0 commit comments

Comments
 (0)