How to get Downloadable Product Links data from product object Magento 2?

Retrieve getDownloadableProductLinks() from the Product object in Magento 2 to fetch download product links information.

Core module module-downloadable contains the extension attributes type for the Magento\Catalog\Api\Data\ProductInterface. Attribute code downloadable_product_links used for the links details in the product object.

5 Replies to “How to get Downloadable Product Links data from product object Magento 2?”

  1. When `get($sku)` fails with `NoSuchEntityException` then `$linksData` returns null, not array.
    `$linksData = [];` should be located BEFORE `try {`

    1. No, You need to create Block Class to directly call the method. I have used Model class, you need to call model funnction to the Block class and call block method to the templates.

Leave a Reply