Skip to content

Commit 407737f

Browse files
committed
Links to the downloadable_product_samples are direct links
1 parent 211dd25 commit 407737f

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

app/code/Magento/DownloadableGraphQl/Model/Resolver/Product/DownloadableOptions.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
use Magento\Framework\GraphQl\Config\Element\Field;
2020
use Magento\Framework\GraphQl\Query\EnumLookup;
2121
use Magento\Framework\GraphQl\Query\ResolverInterface;
22+
use Magento\Framework\App\ObjectManager;
23+
use Magento\Framework\UrlInterface;
2224

2325
/**
2426
* @inheritdoc
@@ -47,22 +49,32 @@ class DownloadableOptions implements ResolverInterface
4749
*/
4850
private $linkCollection;
4951

52+
/**
53+
* Downloadable file
54+
*
55+
* @var UrlInterface
56+
*/
57+
private $urlBuilder;
58+
5059
/**
5160
* @param EnumLookup $enumLookup
5261
* @param DownloadableHelper $downloadableHelper
5362
* @param SampleCollection $sampleCollection
5463
* @param LinkCollection $linkCollection
64+
* @param File $downloadableFile
5565
*/
5666
public function __construct(
5767
EnumLookup $enumLookup,
5868
DownloadableHelper $downloadableHelper,
5969
SampleCollection $sampleCollection,
60-
LinkCollection $linkCollection
70+
LinkCollection $linkCollection,
71+
UrlInterface $urlBuilder = null
6172
) {
6273
$this->enumLookup = $enumLookup;
6374
$this->downloadableHelper = $downloadableHelper;
6475
$this->sampleCollection = $sampleCollection;
6576
$this->linkCollection = $linkCollection;
77+
$this->urlBuilder = $urlBuilder ?: ObjectManager::getInstance()->get(UrlInterface::class);
6678
}
6779

6880
/**
@@ -165,7 +177,7 @@ private function formatSamples(Collection $samples) : array
165177
$resultData[$sampleKey]['sort_order'] = $sample->getSortOrder();
166178
$resultData[$sampleKey]['sample_type']
167179
= $this->enumLookup->getEnumValueFromField('DownloadableFileTypeEnum', $sample->getSampleType());
168-
$resultData[$sampleKey]['sample_file'] = $sample->getSampleFile();
180+
$resultData[$sampleKey]['sample_file'] = $this->urlBuilder->getUrl('downloadable/download/sample', ['sample_id' => $sample->getId()]);
169181
$resultData[$sampleKey]['sample_url'] = $sample->getSampleUrl();
170182
}
171183
return $resultData;

0 commit comments

Comments
 (0)