getLinkPrice()); } /** * Retrieve calculated links price * * @return int */ private function getLinkPrice() { $result = 0; if ($this->getProduct()->getLinksPurchasedSeparately()) { /** @var \Magento\Wishlist\Model\Item\Option $customOption */ $customOption = $this->getProduct()->getCustomOption('downloadable_link_ids'); if ($customOption) { $links = $this->getLinks(); $linkIds = explode(',', $customOption->getValue()); foreach ($linkIds as $linkId) { if (isset($links[$linkId])) { $result += $links[$linkId]->getPrice(); } } } } return $result; } /** * @return \Magento\Downloadable\Model\Link[] */ private function getLinks() { /** @var \Magento\Downloadable\Model\Product\Type $productType */ $productType = $this->getProduct()->getTypeInstance(); $links = $productType->getLinks($this->getProduct()); return $links; } /** * @inheritdoc */ public function setItem(ItemInterface $item) { $this->item = $item; return $this; } }