diff --git a/Model/LinkRepository.php b/Model/LinkRepository.php new file mode 100644 index 0000000..360bfd2 --- /dev/null +++ b/Model/LinkRepository.php @@ -0,0 +1,23 @@ +productRepository->getById($id); + return $this->getLinksByProduct($product); + } +} diff --git a/Model/OrderItem/OptionsProcessor.php b/Model/OrderItem/OptionsProcessor.php index 5bc0f65..087d2ce 100644 --- a/Model/OrderItem/OptionsProcessor.php +++ b/Model/OrderItem/OptionsProcessor.php @@ -13,7 +13,7 @@ use Magento\SalesGraphQl\Model\OrderItem\OptionsProcessor as SourceOptionsProcessor; use Magento\Sales\Api\Data\OrderItemInterface; -use Magento\Downloadable\Api\LinkRepositoryInterface; +use ScandiPWA\SalesGraphQl\Model\LinkRepository; /** * Process order item options to format for GraphQl output @@ -46,7 +46,7 @@ class OptionsProcessor extends SourceOptionsProcessor protected $linkRepository; public function __construct( - LinkRepositoryInterface $linkRepository + LinkRepository $linkRepository ) { $this->linkRepository = $linkRepository; } @@ -152,12 +152,13 @@ protected function processBundleOptions(array $bundleOptions) * @param $product * @param array $links */ - protected function processDownloadableLinksOptions($product, array $links) { - // Get the product downloadable links - $productLinks = $this->linkRepository->getList($product->getSku()); - $linksOutput = [ 'label' => 'Links', 'linkItems' => []]; + protected function processDownloadableLinksOptions($product, array $links) + { + $productLinks = $this->linkRepository->getListById((int)$product->getProductId()); + + $linksOutput = ['label' => 'Links', 'linkItems' => []]; - foreach($productLinks as $link) { + foreach ($productLinks as $link) { if (in_array($link->getId(), $links)) { $linksOutput['linkItems'][] = $link->getTitle(); }