In Magento 2, how can I update the PDF file of a download product so that old links refers to the new PDF?

I think there are 2 ways to try that:

  1. I can load every links (in this case THE link) of the product and delete them and set the new one. I think it will not be a problem for purchased links in the past because the link interfaces refer to the product sku by this save function:

    $link_repository->save($sku, $link_interface); 

    The product will not be deleted and will conserve its old sku, so the links will be actualized with a new one (right...?).

  2. I can try to change the base64 encoded content of the Link used to set the Link to the product:


Any idea?

$link_repository = $objectManager->create('Magento\Downloadable\Api\LinkRepositoryInterface');
$link_interface = $objectManager->create('\Magento\Downloadable\Api\Data\LinkInterface');   

$old_links = $link_repository->getList($product->getSku());
foreach ($old_links as $old_link) {

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.