Skip to content

Commit 947eaed

Browse files
committed
Fix the error that is wrong link title of a downloadable product when enabling "Use Default Value"
- Update sample title incorrectly
1 parent a242e3a commit 947eaed

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

app/code/Magento/Downloadable/Model/Sample/Builder.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,12 @@ public function build(SampleInterface $sample)
122122
if (!$sample->getSortOrder()) {
123123
$sample->setSortOrder(1);
124124
}
125+
126+
$useDefaultTitle = $this->data['use_default_title'] ?? false;
127+
128+
if ($useDefaultTitle) {
129+
$sample->setTitle(null);
130+
}
125131
$this->resetData();
126132

127133
return $sample;

app/code/Magento/Downloadable/Test/Unit/Model/Sample/BuilderTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ public function testBuild()
8585
{
8686
$data = [
8787
'file' => 'cXVlIHRhbA==',
88+
'use_default_title' => '1',
8889
'type' => 'file'
8990
];
9091
$downloadableData = ['sort_order' => 1];
@@ -123,6 +124,10 @@ public function testBuild()
123124
)->willReturn($fileName);
124125
$this->sampleMock->expects($this->once())->method('setSampleFile')->with($fileName);
125126
$this->sampleMock->expects($this->once())->method('setSortOrder')->with(1);
127+
$useDefaultTitle = $data['use_default_title'] ?? false;
128+
if ($useDefaultTitle) {
129+
$this->sampleMock->expects($this->once())->method('setTitle')->with(null);
130+
}
126131
$this->service->setData($data);
127132

128133
$this->service->build($this->sampleMock);

0 commit comments

Comments
 (0)