Skip to content

Commit 8c18808

Browse files
committed
MAGETWO-52170: Impossible to create Downloadable Product - review fixes
1 parent 3853d0d commit 8c18808

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

app/code/Magento/Downloadable/Model/LinkRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ public function save($sku, LinkInterface $link, $isGlobalScopeContent = true)
184184
throw new InputException(__('Provided link information is invalid.'));
185185
}
186186

187-
if (!($link->getLinkType() === 'url' || $link->getLinkType() === 'file')) {
187+
if (!in_array($link->getLinkType(), ['url', 'file'], true)) {
188188
throw new InputException(__('Invalid link type.'));
189189
}
190190
$title = $link->getTitle();

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ public function build(SampleInterface $sample)
9999
SampleInterface::class
100100
);
101101
if ($sample->getSampleType() === \Magento\Downloadable\Helper\Download::LINK_TYPE_FILE) {
102+
if (!isset($this->data['file'])) {
103+
throw new \Magento\Framework\Exception\LocalizedException(__('Sample file not provided'));
104+
}
102105
$fileName = $this->downloadableFile->moveFileFromTmp(
103106
$this->getComponent()->getBaseTmpPath(),
104107
$this->getComponent()->getBasePath(),

app/code/Magento/Downloadable/Model/SampleRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ public function save(
190190
throw new InputException(__('Provided sample information is invalid.'));
191191
}
192192

193-
if (!($sample->getSampleType() === 'url' || $sample->getSampleType() === 'file')) {
193+
if (!in_array($sample->getSampleType(), ['url', 'file'], true)) {
194194
throw new InputException(__('Invalid sample type.'));
195195
}
196196

0 commit comments

Comments
 (0)