Skip to content

Commit 636df3d

Browse files
committed
MC-40850: Not able to save downloadable product with sample link after creating a future staging update with end date from the Downloadable Product page
1 parent 2b943ed commit 636df3d

File tree

5 files changed

+56
-6
lines changed

5 files changed

+56
-6
lines changed

app/code/Magento/Downloadable/Model/Sample/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 Samples.
1313
*/
1414
class DeleteHandler implements ExtensionInterface
1515
{
@@ -27,6 +27,8 @@ public function __construct(SampleRepository $sampleRepository)
2727
}
2828

2929
/**
30+
* Delete Downloadable Samples for the provided Entity.
31+
*
3032
* @param object $entity
3133
* @param array $arguments
3234
* @return \Magento\Catalog\Api\Data\ProductInterface|object
@@ -42,6 +44,8 @@ public function execute($entity, $arguments = [])
4244
foreach ($this->sampleRepository->getList($entity->getSku()) as $sample) {
4345
$this->sampleRepository->delete($sample->getId());
4446
}
47+
$entity->setDownloadableSamples(null);
48+
4549
return $entity;
4650
}
4751
}

app/code/Magento/Downloadable/Model/Sample/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 Samples.
1313
*/
1414
class ReadHandler implements ExtensionInterface
1515
{
@@ -27,6 +27,8 @@ public function __construct(SampleRepository $sampleRepository)
2727
}
2828

2929
/**
30+
* Read Downloadable Samples for the provided Entity.
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
$samples = $this->sampleRepository->getSamplesByProduct($entity);
43-
if ($samples) {
44-
$entityExtension->setDownloadableProductSamples($samples);
45-
}
45+
$entityExtension->setDownloadableProductSamples($samples);
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="AssertStorefrontNoSampleOnDownloadableProductPageActionGroup">
12+
<annotations>
13+
<description>Validates that the provided Sample Title is NOT present on Downloadable Product details page.</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="sampleTitle" type="string" defaultValue="{{downloadableSampleUrl.title}}"/>
17+
</arguments>
18+
19+
<waitForElementVisible selector="{{StorefrontDownloadableProductSection.downloadableSamplesListSection}}" stepKey="waitForDownloadableSamplesList"/>
20+
<dontSeeElement selector="{{StorefrontDownloadableProductSection.downloadableSampleLabel(sampleTitle)}}" stepKey="dontSeeDownloadableSample"/>
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="AssertStorefrontSampleOnDownloadableProductPageActionGroup">
12+
<annotations>
13+
<description>Validates that the provided Sample Title is present on Downloadable Product details page.</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="sampleTitle" type="string" defaultValue="{{downloadableSampleUrl.title}}"/>
17+
</arguments>
18+
19+
<waitForElementVisible selector="{{StorefrontDownloadableProductSection.downloadableSamplesListSection}}" stepKey="waitForDownloadableSamplesList"/>
20+
<seeElement selector="{{StorefrontDownloadableProductSection.downloadableSampleLabel(sampleTitle)}}" stepKey="seeDownloadableSample"/>
21+
</actionGroup>
22+
</actionGroups>

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@
1313
<element name="downloadableLinkLabel" type="text" selector="//label[contains(., '{{title}}')]" parameterized="true" timeout="30"/>
1414
<element name="downloadableLinkByTitle" type="input" selector="//*[@id='downloadable-links-list']/*[contains(.,'{{title}}')]//input" parameterized="true" timeout="30"/>
1515
<element name="downloadableLinkSampleByTitle" type="text" selector="//label[contains(., '{{title}}')]/a[contains(@class, 'sample link')]" parameterized="true"/>
16-
<element name="downloadableSampleLabel" type="text" selector="//a[contains(.,normalize-space('{{title}}'))]" parameterized="true" timeout="30"/>
16+
<element name="downloadableSampleLabel" type="text" selector="//dd[@class='item samples-item']/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']" />
1919
<element name="downloadableLinksListSection" type="text" selector="#downloadable-links-list" timeout="30"/>
20+
<element name="downloadableSamplesListSection" type="text" selector=".items.samples" timeout="30"/>
2021
</section>
2122
</sections>

0 commit comments

Comments
 (0)