Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Link.php
Go to the documentation of this file.
1 <?php
7 
10 
22 {
23  const XML_PATH_LINKS_TITLE = 'catalog/downloadable/links_title';
24 
25  const XML_PATH_DEFAULT_DOWNLOADS_NUMBER = 'catalog/downloadable/downloads_number';
26 
27  const XML_PATH_TARGET_NEW_WINDOW = 'catalog/downloadable/links_target_new_window';
28 
29  const XML_PATH_CONFIG_IS_SHAREABLE = 'catalog/downloadable/shareable';
30 
31  const LINK_SHAREABLE_YES = 1;
32 
33  const LINK_SHAREABLE_NO = 0;
34 
36 
40  const KEY_TITLE = 'title';
41  const KEY_SORT_ORDER = 'sort_order';
42  const KEY_IS_SHAREABLE = 'is_shareable';
43  const KEY_PRICE = 'price';
44  const KEY_NUMBER_OF_DOWNLOADS = 'number_of_downloads';
45  const KEY_LINK_TYPE = 'link_type';
46  const KEY_LINK_FILE = 'link_file';
47  const KEY_LINK_FILE_CONTENT = 'link_file_content';
48  const KEY_LINK_URL = 'link_url';
49  const KEY_SAMPLE_TYPE = 'sample_type';
50  const KEY_SAMPLE_FILE = 'sample_file';
51  const KEY_SAMPLE_FILE_CONTENT = 'sample_file_content';
52  const KEY_SAMPLE_URL = 'sample_url';
64  public function __construct(
65  \Magento\Framework\Model\Context $context,
66  \Magento\Framework\Registry $registry,
67  \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory,
68  \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory,
69  \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
70  \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
71  array $data = []
72  ) {
73  parent::__construct(
74  $context,
75  $registry,
76  $extensionFactory,
78  $resource,
79  $resourceCollection,
80  $data
81  );
82  }
83 
89  protected function _construct()
90  {
91  $this->_init(\Magento\Downloadable\Model\ResourceModel\Link::class);
92  parent::_construct();
93  }
94 
98  public function afterSave()
99  {
100  $this->getResource()->saveItemTitleAndPrice($this);
101  return parent::afterSave();
102  }
103 
109  public function getBaseTmpPath()
110  {
111  return 'downloadable/tmp/links';
112  }
113 
119  public function getBasePath()
120  {
121  return 'downloadable/files/links';
122  }
123 
129  public function getBaseSampleTmpPath()
130  {
131  return 'downloadable/tmp/link_samples';
132  }
133 
139  public function getBaseSamplePath()
140  {
141  return 'downloadable/files/link_samples';
142  }
143 
152  {
153  return $this->_getResource()->getSearchableData($productId, $storeId);
154  }
155 
160  public function getTitle()
161  {
162  return $this->getData(self::KEY_TITLE);
163  }
164 
169  public function getPrice()
170  {
171  return $this->getData(self::KEY_PRICE);
172  }
173 
178  public function getIsShareable()
179  {
180  return $this->getData(self::KEY_IS_SHAREABLE);
181  }
182 
187  public function getSortOrder()
188  {
189  return $this->getData(self::KEY_SORT_ORDER);
190  }
191 
196  public function getNumberOfDownloads()
197  {
198  return $this->getData(self::KEY_NUMBER_OF_DOWNLOADS);
199  }
200 
205  public function getLinkType()
206  {
207  return $this->getData(self::KEY_LINK_TYPE);
208  }
209 
214  public function getLinkFile()
215  {
216  return $this->getData(self::KEY_LINK_FILE);
217  }
218 
224  public function getLinkFileContent()
225  {
226  return $this->getData(self::KEY_LINK_FILE_CONTENT);
227  }
228 
233  public function getLinkUrl()
234  {
235  return $this->getData(self::KEY_LINK_URL);
236  }
237 
242  public function getSampleType()
243  {
244  return $this->getData(self::KEY_SAMPLE_TYPE);
245  }
246 
251  public function getSampleFile()
252  {
253  return $this->getData(self::KEY_SAMPLE_FILE);
254  }
255 
261  public function getSampleFileContent()
262  {
263  return $this->getData(self::KEY_SAMPLE_FILE_CONTENT);
264  }
265 
270  public function getSampleUrl()
271  {
272  return $this->getData(self::KEY_SAMPLE_URL);
273  }
274 
275  //@codeCoverageIgnoreStart
276 
281  public function setTitle($title)
282  {
283  return $this->setData(self::KEY_TITLE, $title);
284  }
285 
290  public function setSortOrder($sortOrder)
291  {
292  return $this->setData(self::KEY_SORT_ORDER, $sortOrder);
293  }
294 
299  public function setIsShareable($isShareable)
300  {
301  return $this->setData(self::KEY_IS_SHAREABLE, $isShareable);
302  }
303 
310  public function setPrice($price)
311  {
312  return $this->setData(self::KEY_PRICE, $price);
313  }
314 
322  public function setNumberOfDownloads($numberOfDownloads)
323  {
324  return $this->setData(self::KEY_NUMBER_OF_DOWNLOADS, $numberOfDownloads);
325  }
326 
331  public function setLinkType($linkType)
332  {
333  return $this->setData(self::KEY_LINK_TYPE, $linkType);
334  }
335 
342  public function setLinkFile($linkFile)
343  {
344  return $this->setData(self::KEY_LINK_FILE, $linkFile);
345  }
346 
353  public function setLinkFileContent(\Magento\Downloadable\Api\Data\File\ContentInterface $linkFileContent = null)
354  {
355  return $this->setData(self::KEY_LINK_FILE_CONTENT, $linkFileContent);
356  }
357 
364  public function setLinkUrl($linkUrl)
365  {
366  return $this->setData(self::KEY_LINK_URL, $linkUrl);
367  }
368 
373  public function setSampleType($sampleType)
374  {
375  return $this->setData(self::KEY_SAMPLE_TYPE, $sampleType);
376  }
377 
384  public function setSampleFile($sampleFile)
385  {
386  return $this->setData(self::KEY_SAMPLE_FILE, $sampleFile);
387  }
388 
395  public function setSampleFileContent(
396  \Magento\Downloadable\Api\Data\File\ContentInterface $sampleFileContent = null
397  ) {
398  return $this->setData(self::KEY_SAMPLE_FILE_CONTENT, $sampleFileContent);
399  }
400 
407  public function setSampleUrl($sampleUrl)
408  {
409  return $this->setData(self::KEY_SAMPLE_URL, $sampleUrl);
410  }
411 
417  public function getExtensionAttributes()
418  {
419  return $this->_getExtensionAttributes();
420  }
421 
428  public function setExtensionAttributes(\Magento\Downloadable\Api\Data\LinkExtensionInterface $extensionAttributes)
429  {
430  return $this->_setExtensionAttributes($extensionAttributes);
431  }
432 
433  //@codeCoverageIgnoreEnd
434 }
$title
Definition: default.phtml:14
_setExtensionAttributes(\Magento\Framework\Api\ExtensionAttributesInterface $extensionAttributes)
$resource
Definition: bulk.php:12
$price