Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Downloadable.php
Go to the documentation of this file.
1 <?php
7 
11 
13 {
17  const PRICE_CODE = 'configured_price';
18 
22  private $item;
23 
27  public function getValue()
28  {
29  return max(0, parent::getValue() + $this->getLinkPrice());
30  }
31 
37  private function getLinkPrice()
38  {
39  $result = 0;
40  if ($this->getProduct()->getLinksPurchasedSeparately()) {
42  $customOption = $this->getProduct()->getCustomOption('downloadable_link_ids');
43  if ($customOption) {
44  $links = $this->getLinks();
45  $linkIds = explode(',', $customOption->getValue());
46  foreach ($linkIds as $linkId) {
47  if (isset($links[$linkId])) {
48  $result += $links[$linkId]->getPrice();
49  }
50  }
51  }
52  }
53  return $result;
54  }
55 
59  private function getLinks()
60  {
62  $productType = $this->getProduct()->getTypeInstance();
63  $links = $productType->getLinks($this->getProduct());
64  return $links;
65  }
66 
70  public function setItem(ItemInterface $item)
71  {
72  $this->item = $item;
73  return $this;
74  }
75 }
$customOption
Definition: products.php:73