Skip to content

Commit 9fe68dc

Browse files
committed
Merge remote-tracking branch 'origin/MC-39784' into 2.4-develop-pr123
2 parents 68ca3ad + bd5a4fc commit 9fe68dc

File tree

5 files changed

+55
-5
lines changed

5 files changed

+55
-5
lines changed

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)