Skip to content

patch-19344 : Fixed Sample Link Issue in Downloadable product #19344 #19378

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions app/code/Magento/Downloadable/Model/Sample/ReadHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

use Magento\Downloadable\Api\SampleRepositoryInterface as SampleRepository;
use Magento\Framework\EntityManager\Operation\ExtensionInterface;

use Magento\Framework\App\RequestInterface;
/**
* Class ReadHandler
*/
Expand All @@ -21,9 +21,16 @@ class ReadHandler implements ExtensionInterface
/**
* @param SampleRepository $sampleRepository
*/
public function __construct(SampleRepository $sampleRepository)

/**
* @var RequestInterface
*/
protected $request;

public function __construct(SampleRepository $sampleRepository,RequestInterface $request)
{
$this->sampleRepository = $sampleRepository;
$this->request = $request;
}

/**
Expand All @@ -40,7 +47,10 @@ public function execute($entity, $arguments = [])
}
$entityExtension = $entity->getExtensionAttributes();
$samples = $this->sampleRepository->getSamplesByProduct($entity);
if ($samples) {

$downloadable = $this->request->getPost('downloadable');

if ($samples && isset($downloadable['sample']) && is_array($downloadable['sample'])) {
$entityExtension->setDownloadableProductSamples($samples);
}
$entity->setExtensionAttributes($entityExtension);
Expand Down