Skip to content

Commit 2b943ed

Browse files
authored
Merge pull request #6622 from magento-tsg/2.4-develop-pr123
[Arrows] Fixes for 2.4 (pr123) (2.4-develop)
2 parents 0d3d7bb + dcd898d commit 2b943ed

File tree

25 files changed

+755
-107
lines changed

25 files changed

+755
-107
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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\Plugin\Api\ProductLinkRepositoryInterface;
9+
10+
use Magento\Catalog\Api\ProductRepositoryInterface;
11+
use Magento\Catalog\Api\ProductLinkRepositoryInterface;
12+
use Magento\Catalog\Model\Indexer\Product\Full as FullProductIndexer;
13+
14+
/**
15+
* Product reindexing after delete by id links plugin.
16+
*/
17+
class ReindexAfterDeleteByIdProductLinksPlugin
18+
{
19+
/**
20+
* @var FullProductIndexer
21+
*/
22+
private $fullProductIndexer;
23+
24+
/**
25+
* @var ProductRepositoryInterface
26+
*/
27+
private $productRepository;
28+
29+
/**
30+
* @param FullProductIndexer $fullProductIndexer
31+
* @param ProductRepositoryInterface $productRepository
32+
*/
33+
public function __construct(FullProductIndexer $fullProductIndexer, ProductRepositoryInterface $productRepository)
34+
{
35+
$this->fullProductIndexer = $fullProductIndexer;
36+
$this->productRepository = $productRepository;
37+
}
38+
39+
/**
40+
* Complex reindex after product links has been deleted.
41+
*
42+
* @param ProductLinkRepositoryInterface $subject
43+
* @param bool $result
44+
* @param string $sku
45+
* @param string $type
46+
* @param string $linkedProductSku
47+
* @return bool
48+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
49+
*/
50+
public function afterDeleteById(ProductLinkRepositoryInterface $subject, bool $result, $sku): bool
51+
{
52+
$product = $this->productRepository->get($sku);
53+
$this->fullProductIndexer->executeRow($product->getId());
54+
55+
return $result;
56+
}
57+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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\Plugin\Api\ProductLinkRepositoryInterface;
9+
10+
use Magento\Catalog\Api\ProductRepositoryInterface;
11+
use Magento\Catalog\Api\ProductLinkRepositoryInterface;
12+
use Magento\Catalog\Api\Data\ProductLinkInterface;
13+
use Magento\Catalog\Model\Indexer\Product\Full as FullProductIndexer;
14+
15+
/**
16+
* Product reindexing after save links plugin.
17+
*/
18+
class ReindexAfterSaveProductLinksPlugin
19+
{
20+
/**
21+
* @var FullProductIndexer
22+
*/
23+
private $fullProductIndexer;
24+
25+
/**
26+
* @var ProductRepositoryInterface
27+
*/
28+
private $productRepository;
29+
30+
/**
31+
* @param FullProductIndexer $fullProductIndexer
32+
* @param ProductRepositoryInterface $productRepository
33+
*/
34+
public function __construct(FullProductIndexer $fullProductIndexer, ProductRepositoryInterface $productRepository)
35+
{
36+
$this->fullProductIndexer = $fullProductIndexer;
37+
$this->productRepository = $productRepository;
38+
}
39+
40+
/**
41+
* Complex reindex after product links has been saved.
42+
*
43+
* @param ProductLinkRepositoryInterface $subject
44+
* @param bool $result
45+
* @param ProductLinkInterface $entity
46+
* @return bool
47+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
48+
*/
49+
public function afterSave(ProductLinkRepositoryInterface $subject, bool $result, ProductLinkInterface $entity): bool
50+
{
51+
$product = $this->productRepository->get($entity->getSku());
52+
$this->fullProductIndexer->executeRow($product->getId());
53+
54+
return $result;
55+
}
56+
}

app/code/Magento/Catalog/etc/webapi_rest/di.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,8 @@
4040
<argument name="deserializer" xsi:type="object">Magento\Catalog\Model\Product\Webapi\Rest\RequestTypeBasedDeserializer</argument>
4141
</arguments>
4242
</type>
43+
<type name="Magento\Catalog\Api\ProductLinkRepositoryInterface">
44+
<plugin name="reindex_after_save_product_links" type="Magento\Catalog\Plugin\Api\ProductLinkRepositoryInterface\ReindexAfterSaveProductLinksPlugin"/>
45+
<plugin name="reindex_after_delete_by_id_product_links" type="Magento\Catalog\Plugin\Api\ProductLinkRepositoryInterface\ReindexAfterDeleteByIdProductLinksPlugin"/>
46+
</type>
4347
</config>

app/code/Magento/Catalog/etc/webapi_soap/di.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,8 @@
4040
<argument name="deserializer" xsi:type="object">Magento\Framework\Webapi\Rest\Request\Deserializer\Xml</argument>
4141
</arguments>
4242
</type>
43+
<type name="Magento\Catalog\Api\ProductLinkRepositoryInterface">
44+
<plugin name="reindex_after_save_product_links" type="Magento\Catalog\Plugin\Api\ProductLinkRepositoryInterface\ReindexAfterSaveProductLinksPlugin"/>
45+
<plugin name="reindex_after_delete_by_id_product_links" type="Magento\Catalog\Plugin\Api\ProductLinkRepositoryInterface\ReindexAfterDeleteByIdProductLinksPlugin"/>
46+
</type>
4347
</config>

app/code/Magento/Catalog/view/adminhtml/web/catalog/product/composite/configure.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,14 @@ define([
4747
* Initialize object
4848
*/
4949
initialize: function () {
50-
var self = this;
50+
var self = this,
51+
popupDialog = jQuery('#product_composite_configure');
5152

5253
this._initWindowElements();
5354
jQuery.async('#product_composite_configure', function (el) {
55+
if (el !== popupDialog[0]) {
56+
el = popupDialog[0];
57+
}
5458
self.dialog = jQuery(el).modal({
5559
title: jQuery.mage.__('Configure Product'),
5660
type: 'slide',

app/code/Magento/Checkout/view/frontend/templates/onepage/link.phtml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,27 @@
44
* See COPYING.txt for license details.
55
*/
66

7-
/** @var $block \Magento\Checkout\Block\Onepage\Link */
7+
use Magento\Checkout\Block\Onepage\Link;
8+
use Magento\Framework\Escaper;
9+
10+
/**
11+
* @var Link $block
12+
* @var Escaper $escaper
13+
*/
814
?>
9-
<?php if ($block->isPossibleOnepageCheckout()) :?>
15+
<?php if ($block->isPossibleOnepageCheckout()): ?>
1016
<button type="button"
1117
data-role="proceed-to-checkout"
12-
title="<?= $block->escapeHtmlAttr(__('Proceed to Checkout')) ?>"
18+
title="<?= $escaper->escapeHtmlAttr(__('Proceed to Checkout')) ?>"
1319
data-mage-init='{
1420
"Magento_Checkout/js/proceed-to-checkout":{
15-
"checkoutUrl":"<?= $block->escapeJs($block->escapeUrl($block->getCheckoutUrl())) ?>"
21+
"checkoutUrl":"<?= $escaper->escapeJs($block->getCheckoutUrl()) ?>"
1622
}
1723
}'
1824
class="action primary checkout<?= ($block->isDisabled()) ? ' disabled' : '' ?>"
19-
<?php if ($block->isDisabled()) :?>
25+
<?php if ($block->isDisabled()): ?>
2026
disabled="disabled"
2127
<?php endif; ?>>
22-
<span><?= $block->escapeHtml(__('Proceed to Checkout')) ?></span>
28+
<span><?= $escaper->escapeHtml(__('Proceed to Checkout')) ?></span>
2329
</button>
2430
<?php endif?>

app/code/Magento/Checkout/view/frontend/web/js/model/totals.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ define([
2222
quoteItems(newValue.items);
2323
});
2424

25-
if (quoteSubtotal !== subtotalAmount) {
25+
if (!isNaN(subtotalAmount) && quoteSubtotal !== subtotalAmount) {
2626
customerData.reload(['cart'], false);
2727
}
2828

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AdminCustomerWishlistConfigureItemActionGroup">
12+
<arguments>
13+
<argument name="title" type="string" defaultValue="{{Attribute.label}}"/>
14+
<argument name="option" type="string" defaultValue="option1"/>
15+
<argument name="quantity" type="string" defaultValue="2"/>
16+
<argument name="productName" type="string" defaultValue="{{ApiConfigurableProductWithOutCategory.name}}"/>
17+
</arguments>
18+
<click selector="{{AdminCustomerWishlistSection.configureButton(productName)}}" stepKey="clickConfigureButton"/>
19+
<waitForElementVisible selector="{{AdminCustomerWishlistSection.productAttributeOptionsDropDown(title)}}" stepKey="waitForConfigurableOption"/>
20+
<selectOption selector="{{AdminCustomerWishlistSection.productAttributeOptionsDropDown(title)}}" userInput="{{option}}" stepKey="selectConfigurableOption"/>
21+
<fillField selector="{{AdminOrderFormConfigureProductSection.quantity}}" userInput="{{quantity}}" stepKey="fillQty"/>
22+
<click selector="{{AdminOrderFormConfigureProductSection.ok}}" stepKey="confirmSave"/>
23+
</actionGroup>
24+
</actionGroups>

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,8 @@
1414
<element name="deleteButton" type="text" selector="//*[@id='wishlistGrid_table']//*[@data-column='action']//*[text()='Delete']"/>
1515
<element name="deleteConfirm" type="button" selector=".modal-popup.confirm .action-primary.action-accept"/>
1616
<element name="gridTable" type="text" selector="#wishlistGrid_table"/>
17+
<element name="configureButton" type="text" selector="//table[@id='wishlistGrid_table']//tbody//td[@data-column='product_name' and contains(text(),'{{productName}}')]/parent::tr//td[@data-column='action']//a[@class='configure-item-link']" timeout="30" parameterized="true"/>
18+
<element name="productAttributeOptionsDropDown" type="text" selector="//label[contains(.,'{{var1}}')]/following::div[contains(@class,'control')]//select" parameterized="true"/>
19+
<element name="productQty" type="text" selector="table#wishlistGrid_table td.col-number[data-column=qty]"/>
1720
</section>
1821
</sections>

app/code/Magento/Downloadable/Model/Link/DeleteHandler.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use Magento\Framework\EntityManager\Operation\ExtensionInterface;
1010

1111
/**
12-
* Class DeleteHandler
12+
* Delete Handler for Downloadable Product Links.
1313
*/
1414
class DeleteHandler implements ExtensionInterface
1515
{
@@ -27,6 +27,8 @@ public function __construct(LinkRepository $linkRepository)
2727
}
2828

2929
/**
30+
* Delete Downloadable Links for the provided Product.
31+
*
3032
* @param object $entity
3133
* @param array $arguments
3234
* @return \Magento\Catalog\Api\Data\ProductInterface|object
@@ -41,6 +43,8 @@ public function execute($entity, $arguments = [])
4143
foreach ($this->linkRepository->getList($entity->getSku()) as $link) {
4244
$this->linkRepository->delete($link->getId());
4345
}
46+
$entity->setDownloadableLinks(null);
47+
4448
return $entity;
4549
}
4650
}

app/code/Magento/Downloadable/Model/Link/ReadHandler.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use Magento\Framework\EntityManager\Operation\ExtensionInterface;
1010

1111
/**
12-
* Class ReadHandler
12+
* Read Handler for Downloadable Product Links.
1313
*/
1414
class ReadHandler implements ExtensionInterface
1515
{
@@ -27,6 +27,8 @@ public function __construct(LinkRepository $linkRepository)
2727
}
2828

2929
/**
30+
* Read Downloadable Links for the provided Product.
31+
*
3032
* @param object $entity
3133
* @param array $arguments
3234
* @return \Magento\Catalog\Api\Data\ProductInterface|object
@@ -40,10 +42,9 @@ public function execute($entity, $arguments = [])
4042
}
4143
$entityExtension = $entity->getExtensionAttributes();
4244
$links = $this->linkRepository->getLinksByProduct($entity);
43-
if ($links) {
44-
$entityExtension->setDownloadableProductLinks($links);
45-
}
45+
$entityExtension->setDownloadableProductLinks($links);
4646
$entity->setExtensionAttributes($entityExtension);
47+
4748
return $entity;
4849
}
4950
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AssertStorefrontLinkOnDownloadableProductPageActionGroup">
12+
<annotations>
13+
<description>Validates that the provided Link Title is present on Downloadable Product details page.</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="linkTitle" type="string" defaultValue="{{downloadableLink.title}}"/>
17+
</arguments>
18+
19+
<waitForElementVisible selector="{{StorefrontDownloadableProductSection.downloadableLinksListSection}}" stepKey="waitForDownloadableLinksList"/>
20+
<see selector="{{StorefrontDownloadableProductSection.downloadableLinksListSection}}" userInput="{{linkTitle}}" stepKey="seeDownloadableLink"/>
21+
</actionGroup>
22+
</actionGroups>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AssertStorefrontNoLinkOnDownloadableProductPageActionGroup">
12+
<annotations>
13+
<description>Validates that the provided Link Title is NOT present on Downloadable Product details page.</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="linkTitle" type="string" defaultValue="{{downloadableLink.title}}"/>
17+
</arguments>
18+
19+
<waitForElementVisible selector="{{StorefrontDownloadableProductSection.downloadableLinksListSection}}" stepKey="waitForDownloadableLinksList"/>
20+
<dontSee selector="{{StorefrontDownloadableProductSection.downloadableLinksListSection}}" userInput="{{linkTitle}}" stepKey="dontSeeDownloadableLink"/>
21+
</actionGroup>
22+
</actionGroups>

app/code/Magento/Downloadable/Test/Mftf/Section/StorefrontDownloadableProductSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@
1616
<element name="downloadableSampleLabel" type="text" selector="//a[contains(.,normalize-space('{{title}}'))]" parameterized="true" timeout="30"/>
1717
<element name="downloadableLinkSelectAllCheckbox" type="checkbox" selector="#links_all" />
1818
<element name="downloadableLinkSelectAllLabel" type="text" selector="label[for='links_all']" />
19+
<element name="downloadableLinksListSection" type="text" selector="#downloadable-links-list" timeout="30"/>
1920
</section>
2021
</sections>

0 commit comments

Comments
 (0)