Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Data Fields | Protected Member Functions
Link Class Reference
Inheritance diagram for Link:
AbstractExtensibleModel ComponentInterface LinkInterface AbstractModel CustomAttributesDataInterface ExtensibleDataInterface DataObject ExtensibleDataInterface

Public Member Functions

 __construct (\Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory, \Magento\Framework\Model\ResourceModel\AbstractResource $resource=null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection=null, array $data=[])
 
 afterSave ()
 
 getBaseTmpPath ()
 
 getBasePath ()
 
 getBaseSampleTmpPath ()
 
 getBaseSamplePath ()
 
 getSearchableData ($productId, $storeId)
 
 getTitle ()
 
 getPrice ()
 
 getIsShareable ()
 
 getSortOrder ()
 
 getNumberOfDownloads ()
 
 getLinkType ()
 
 getLinkFile ()
 
 getLinkFileContent ()
 
 getLinkUrl ()
 
 getSampleType ()
 
 getSampleFile ()
 
 getSampleFileContent ()
 
 getSampleUrl ()
 
 setTitle ($title)
 
 setSortOrder ($sortOrder)
 
 setIsShareable ($isShareable)
 
 setPrice ($price)
 
 setNumberOfDownloads ($numberOfDownloads)
 
 setLinkType ($linkType)
 
 setLinkFile ($linkFile)
 
 setLinkFileContent (\Magento\Downloadable\Api\Data\File\ContentInterface $linkFileContent=null)
 
 setLinkUrl ($linkUrl)
 
 setSampleType ($sampleType)
 
 setSampleFile ($sampleFile)
 
 setSampleFileContent (\Magento\Downloadable\Api\Data\File\ContentInterface $sampleFileContent=null)
 
 setSampleUrl ($sampleUrl)
 
 getExtensionAttributes ()
 
 setExtensionAttributes (\Magento\Downloadable\Api\Data\LinkExtensionInterface $extensionAttributes)
 
- Public Member Functions inherited from AbstractExtensibleModel
 __construct (\Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, ExtensionAttributesFactory $extensionFactory, AttributeValueFactory $customAttributeFactory, \Magento\Framework\Model\ResourceModel\AbstractResource $resource=null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection=null, array $data=[])
 
 getCustomAttributes ()
 
 getCustomAttribute ($attributeCode)
 
 setCustomAttributes (array $attributes)
 
 setCustomAttribute ($attributeCode, $attributeValue)
 
 setData ($key, $value=null)
 
 unsetData ($key=null)
 
 getData ($key='', $index=null)
 
 setId ($value)
 
 __sleep ()
 
 __wakeup ()
 
- Public Member Functions inherited from AbstractModel
 __construct (\Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\Model\ResourceModel\AbstractResource $resource=null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection=null, array $data=[])
 
 __sleep ()
 
 __wakeup ()
 
 setIdFieldName ($name)
 
 getIdFieldName ()
 
 getId ()
 
 setId ($value)
 
 isDeleted ($isDeleted=null)
 
 hasDataChanges ()
 
 setData ($key, $value=null)
 
 unsetData ($key=null)
 
 setDataChanges ($value)
 
 getOrigData ($key=null)
 
 setOrigData ($key=null, $data=null)
 
 dataHasChangedFor ($field)
 
 getResourceName ()
 
 getResourceCollection ()
 
 getCollection ()
 
 load ($modelId, $field=null)
 
 beforeLoad ($identifier, $field=null)
 
 afterLoad ()
 
 isSaveAllowed ()
 
 setHasDataChanges ($flag)
 
 save ()
 
 afterCommitCallback ()
 
 isObjectNew ($flag=null)
 
 beforeSave ()
 
 validateBeforeSave ()
 
 getCacheTags ()
 
 cleanModelCache ()
 
 afterSave ()
 
 delete ()
 
 beforeDelete ()
 
 afterDelete ()
 
 afterDeleteCommit ()
 
 getResource ()
 
 getEntityId ()
 
 setEntityId ($entityId)
 
 clearInstance ()
 
 getStoredData ()
 
 getEventPrefix ()
 
- Public Member Functions inherited from DataObject
 __construct (array $data=[])
 
 addData (array $arr)
 
 setData ($key, $value=null)
 
 unsetData ($key=null)
 
 getData ($key='', $index=null)
 
 getDataByPath ($path)
 
 getDataByKey ($key)
 
 setDataUsingMethod ($key, $args=[])
 
 getDataUsingMethod ($key, $args=null)
 
 hasData ($key='')
 
 toArray (array $keys=[])
 
 convertToArray (array $keys=[])
 
 toXml (array $keys=[], $rootName='item', $addOpenTag=false, $addCdata=true)
 
 convertToXml (array $arrAttributes=[], $rootName='item', $addOpenTag=false, $addCdata=true)
 
 toJson (array $keys=[])
 
 convertToJson (array $keys=[])
 
 toString ($format='')
 
 __call ($method, $args)
 
 isEmpty ()
 
 serialize ($keys=[], $valueSeparator='=', $fieldSeparator=' ', $quote='"')
 
 debug ($data=null, &$objects=[])
 
 offsetSet ($offset, $value)
 
 offsetExists ($offset)
 
 offsetUnset ($offset)
 
 offsetGet ($offset)
 

Data Fields

const XML_PATH_LINKS_TITLE = 'catalog/downloadable/links_title'
 
const XML_PATH_DEFAULT_DOWNLOADS_NUMBER = 'catalog/downloadable/downloads_number'
 
const XML_PATH_TARGET_NEW_WINDOW = 'catalog/downloadable/links_target_new_window'
 
const XML_PATH_CONFIG_IS_SHAREABLE = 'catalog/downloadable/shareable'
 
const LINK_SHAREABLE_YES = 1
 
const LINK_SHAREABLE_NO = 0
 
const LINK_SHAREABLE_CONFIG = 2
 
const KEY_TITLE = 'title'
 
const KEY_SORT_ORDER = 'sort_order'
 
const KEY_IS_SHAREABLE = 'is_shareable'
 
const KEY_PRICE = 'price'
 
const KEY_NUMBER_OF_DOWNLOADS = 'number_of_downloads'
 
const KEY_LINK_TYPE = 'link_type'
 
const KEY_LINK_FILE = 'link_file'
 
const KEY_LINK_FILE_CONTENT = 'link_file_content'
 
const KEY_LINK_URL = 'link_url'
 
const KEY_SAMPLE_TYPE = 'sample_type'
 
const KEY_SAMPLE_FILE = 'sample_file'
 
const KEY_SAMPLE_FILE_CONTENT = 'sample_file_content'
 
const KEY_SAMPLE_URL = 'sample_url'
 
- Data Fields inherited from CustomAttributesDataInterface
const CUSTOM_ATTRIBUTES = 'custom_attributes'
 
- Data Fields inherited from ExtensibleDataInterface
const EXTENSION_ATTRIBUTES_KEY = 'extension_attributes'
 

Protected Member Functions

 _construct ()
 
- Protected Member Functions inherited from AbstractExtensibleModel
 filterCustomAttributes ($data)
 
 initializeCustomAttributes ()
 
 convertCustomAttributeValues (array &$customAttributes)
 
 getCustomAttributesCodes ()
 
 _setExtensionAttributes (\Magento\Framework\Api\ExtensionAttributesInterface $extensionAttributes)
 
 _getExtensionAttributes ()
 
- Protected Member Functions inherited from AbstractModel
 _construct ()
 
 _init ($resourceModel)
 
 _setResourceModel ($resourceName, $collectionName=null)
 
 _getResource ()
 
 _getEventData ()
 
 _beforeLoad ($modelId, $field=null)
 
 _afterLoad ()
 
 _hasModelChanged ()
 
 _getValidatorBeforeSave ()
 
 _createValidatorBeforeSave ()
 
 _getValidationRulesBeforeSave ()
 
 _clearReferences ()
 
 _clearData ()
 
- Protected Member Functions inherited from DataObject
 _getData ($key)
 
 _underscore ($name)
 

Additional Inherited Members

- Protected Attributes inherited from AbstractExtensibleModel
 $extensionAttributesFactory
 
 $extensionAttributes
 
 $customAttributeFactory
 
 $customAttributesCodes = null
 
 $customAttributesChanged = false
 
- Protected Attributes inherited from AbstractModel
 $_eventPrefix = 'core_abstract'
 
 $_eventObject = 'object'
 
 $_idFieldName = 'id'
 
 $_hasDataChanges = false
 
 $_origData
 
 $_isDeleted = false
 
 $_resource
 
 $_resourceCollection
 
 $_resourceName
 
 $_collectionName
 
 $_cacheTag = false
 
 $_dataSaveAllowed = true
 
 $_isObjectNew = null
 
 $_validatorBeforeSave = null
 
 $_eventManager
 
 $_cacheManager
 
 $_registry
 
 $_logger
 
 $_appState
 
 $_actionValidator
 
 $storedData = []
 
- Protected Attributes inherited from DataObject
 $_data = []
 
- Static Protected Attributes inherited from DataObject
static $_underscoreCache = []
 

Detailed Description

Downloadable link model

@api @method int getProductId() @method Link setProductId(int $value)

@api

Since
100.0.2

Definition at line 21 of file Link.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( \Magento\Framework\Model\Context  $context,
\Magento\Framework\Registry  $registry,
\Magento\Framework\Api\ExtensionAttributesFactory  $extensionFactory,
\Magento\Framework\Api\AttributeValueFactory  $customAttributeFactory,
\Magento\Framework\Model\ResourceModel\AbstractResource  $resource = null,
\Magento\Framework\Data\Collection\AbstractDb  $resourceCollection = null,
array  $data = [] 
)

#-

Parameters
\Magento\Framework\Model\Context$context
\Magento\Framework\Registry$registry
\Magento\Framework\Api\ExtensionAttributesFactory$extensionFactory
\Magento\Framework\Api\AttributeValueFactory$customAttributeFactory
\Magento\Framework\Model\ResourceModel\AbstractResource$resource
\Magento\Framework\Data\Collection\AbstractDb$resourceCollection
array$data

Definition at line 64 of file Link.php.

72  {
73  parent::__construct(
74  $context,
75  $registry,
76  $extensionFactory,
78  $resource,
79  $resourceCollection,
80  $data
81  );
82  }
$resource
Definition: bulk.php:12

Member Function Documentation

◆ _construct()

_construct ( )
protected

Initialize resource model

Returns
void

Definition at line 89 of file Link.php.

90  {
91  $this->_init(\Magento\Downloadable\Model\ResourceModel\Link::class);
92  parent::_construct();
93  }

◆ afterSave()

afterSave ( )
Returns
$this

Definition at line 98 of file Link.php.

99  {
100  $this->getResource()->saveItemTitleAndPrice($this);
101  return parent::afterSave();
102  }

◆ getBasePath()

getBasePath ( )

Retrieve Base files path

Returns
string

Implements ComponentInterface.

Definition at line 119 of file Link.php.

120  {
121  return 'downloadable/files/links';
122  }

◆ getBaseSamplePath()

getBaseSamplePath ( )

Retrieve base sample path

Returns
string

Definition at line 139 of file Link.php.

140  {
141  return 'downloadable/files/link_samples';
142  }

◆ getBaseSampleTmpPath()

getBaseSampleTmpPath ( )

Retrieve base sample temporary path

Returns
string

Definition at line 129 of file Link.php.

130  {
131  return 'downloadable/tmp/link_samples';
132  }

◆ getBaseTmpPath()

getBaseTmpPath ( )

Retrieve base temporary path

Returns
string

Implements ComponentInterface.

Definition at line 109 of file Link.php.

110  {
111  return 'downloadable/tmp/links';
112  }

◆ getExtensionAttributes()

getExtensionAttributes ( )

{Retrieve existing extension attributes object or create a new one.

Returns
\Magento\Downloadable\Api\Data\LinkExtensionInterface|null
}

Returns
\Magento\Downloadable\Api\Data\LinkExtensionInterface|null

Implements LinkInterface.

Definition at line 417 of file Link.php.

◆ getIsShareable()

getIsShareable ( )

{Link shareable status 0 – No 1 – Yes 2 – Use config default value

Returns
int
} @codeCoverageIgnore

Implements LinkInterface.

Definition at line 178 of file Link.php.

179  {
180  return $this->getData(self::KEY_IS_SHAREABLE);
181  }

◆ getLinkFile()

getLinkFile ( )

{Return file path or null when type is 'url'

Returns
string|null relative file path
} @codeCoverageIgnore

Implements LinkInterface.

Definition at line 214 of file Link.php.

215  {
216  return $this->getData(self::KEY_LINK_FILE);
217  }

◆ getLinkFileContent()

getLinkFileContent ( )

Return file content

Returns
\Magento\Downloadable\Api\Data\File\ContentInterface|null

Implements LinkInterface.

Definition at line 224 of file Link.php.

225  {
226  return $this->getData(self::KEY_LINK_FILE_CONTENT);
227  }

◆ getLinkType()

getLinkType ( )

{

Returns
string
} @codeCoverageIgnore

Implements LinkInterface.

Definition at line 205 of file Link.php.

206  {
207  return $this->getData(self::KEY_LINK_TYPE);
208  }

◆ getLinkUrl()

getLinkUrl ( )

{Return link url or null when type is 'file'

Returns
string|null
} @codeCoverageIgnore

Implements LinkInterface.

Definition at line 233 of file Link.php.

234  {
235  return $this->getData(self::KEY_LINK_URL);
236  }

◆ getNumberOfDownloads()

getNumberOfDownloads ( )

{Number of downloads per user Null for unlimited downloads

Returns
int|null
} @codeCoverageIgnore

Implements LinkInterface.

Definition at line 196 of file Link.php.

197  {
198  return $this->getData(self::KEY_NUMBER_OF_DOWNLOADS);
199  }

◆ getPrice()

getPrice ( )

{Link price

Returns
float
} @codeCoverageIgnore

Implements LinkInterface.

Definition at line 169 of file Link.php.

170  {
171  return $this->getData(self::KEY_PRICE);
172  }

◆ getSampleFile()

getSampleFile ( )

{Return file path or null when type is 'url'

Returns
string|null relative file path
} @codeCoverageIgnore

Implements LinkInterface.

Definition at line 251 of file Link.php.

252  {
253  return $this->getData(self::KEY_SAMPLE_FILE);
254  }

◆ getSampleFileContent()

getSampleFileContent ( )

Return sample file content when type is 'file'

Returns
\Magento\Downloadable\Api\Data\File\ContentInterface|null relative file path

Implements LinkInterface.

Definition at line 261 of file Link.php.

262  {
263  return $this->getData(self::KEY_SAMPLE_FILE_CONTENT);
264  }

◆ getSampleType()

getSampleType ( )

{

Returns
string
} @codeCoverageIgnore

Implements LinkInterface.

Definition at line 242 of file Link.php.

243  {
244  return $this->getData(self::KEY_SAMPLE_TYPE);
245  }

◆ getSampleUrl()

getSampleUrl ( )

{Return URL or NULL when type is 'file'

Returns
string|null file URL
} @codeCoverageIgnore

Implements LinkInterface.

Definition at line 270 of file Link.php.

271  {
272  return $this->getData(self::KEY_SAMPLE_URL);
273  }

◆ getSearchableData()

getSearchableData (   $productId,
  $storeId 
)

Retrieve links searchable data

Parameters
int$productId
int$storeId
Returns
array

Implements ComponentInterface.

Definition at line 151 of file Link.php.

152  {
153  return $this->_getResource()->getSearchableData($productId, $storeId);
154  }

◆ getSortOrder()

getSortOrder ( )

{

Returns
int
} @codeCoverageIgnore

Implements LinkInterface.

Definition at line 187 of file Link.php.

188  {
189  return $this->getData(self::KEY_SORT_ORDER);
190  }

◆ getTitle()

getTitle ( )

{

Returns
string|null
} @codeCoverageIgnore

Implements LinkInterface.

Definition at line 160 of file Link.php.

161  {
162  return $this->getData(self::KEY_TITLE);
163  }

◆ setExtensionAttributes()

setExtensionAttributes ( \Magento\Downloadable\Api\Data\LinkExtensionInterface  $extensionAttributes)

{Set an extension attributes object.

Parameters
\Magento\Downloadable\Api\Data\LinkExtensionInterface$extensionAttributes
Returns
$this
}

Parameters
\Magento\Downloadable\Api\Data\LinkExtensionInterface$extensionAttributes
Returns
$this

Implements LinkInterface.

Definition at line 428 of file Link.php.

429  {
431  }
_setExtensionAttributes(\Magento\Framework\Api\ExtensionAttributesInterface $extensionAttributes)

◆ setIsShareable()

setIsShareable (   $isShareable)
Parameters
int$isShareable
Returns
$this

Implements LinkInterface.

Definition at line 299 of file Link.php.

300  {
301  return $this->setData(self::KEY_IS_SHAREABLE, $isShareable);
302  }

◆ setLinkFile()

setLinkFile (   $linkFile)

Set file path or null when type is 'url'

Parameters
string$linkFile
Returns
$this

Implements LinkInterface.

Definition at line 342 of file Link.php.

343  {
344  return $this->setData(self::KEY_LINK_FILE, $linkFile);
345  }

◆ setLinkFileContent()

setLinkFileContent ( \Magento\Downloadable\Api\Data\File\ContentInterface  $linkFileContent = null)

Set file content

Parameters
\Magento\Downloadable\Api\Data\File\ContentInterface$linkFileContent
Returns
$this

Definition at line 353 of file Link.php.

354  {
355  return $this->setData(self::KEY_LINK_FILE_CONTENT, $linkFileContent);
356  }

◆ setLinkType()

setLinkType (   $linkType)
Parameters
string$linkType
Returns
$this

Implements LinkInterface.

Definition at line 331 of file Link.php.

332  {
333  return $this->setData(self::KEY_LINK_TYPE, $linkType);
334  }

◆ setLinkUrl()

setLinkUrl (   $linkUrl)

Set URL

Parameters
string$linkUrl
Returns
$this

Implements LinkInterface.

Definition at line 364 of file Link.php.

365  {
366  return $this->setData(self::KEY_LINK_URL, $linkUrl);
367  }

◆ setNumberOfDownloads()

setNumberOfDownloads (   $numberOfDownloads)

Set number of downloads per user Null for unlimited downloads

Parameters
int$numberOfDownloads
Returns
$this

Implements LinkInterface.

Definition at line 322 of file Link.php.

323  {
324  return $this->setData(self::KEY_NUMBER_OF_DOWNLOADS, $numberOfDownloads);
325  }

◆ setPrice()

setPrice (   $price)

Set link price

Parameters
float$price
Returns
$this

Implements LinkInterface.

Definition at line 310 of file Link.php.

311  {
312  return $this->setData(self::KEY_PRICE, $price);
313  }
$price

◆ setSampleFile()

setSampleFile (   $sampleFile)

Set file path

Parameters
string$sampleFile
Returns
$this

Implements LinkInterface.

Definition at line 384 of file Link.php.

385  {
386  return $this->setData(self::KEY_SAMPLE_FILE, $sampleFile);
387  }

◆ setSampleFileContent()

setSampleFileContent ( \Magento\Downloadable\Api\Data\File\ContentInterface  $sampleFileContent = null)

Set sample file content

Parameters
\Magento\Downloadable\Api\Data\File\ContentInterface$sampleFileContent
Returns
$this

Definition at line 395 of file Link.php.

397  {
398  return $this->setData(self::KEY_SAMPLE_FILE_CONTENT, $sampleFileContent);
399  }

◆ setSampleType()

setSampleType (   $sampleType)
Parameters
string$sampleType
Returns
$this

Implements LinkInterface.

Definition at line 373 of file Link.php.

374  {
375  return $this->setData(self::KEY_SAMPLE_TYPE, $sampleType);
376  }

◆ setSampleUrl()

setSampleUrl (   $sampleUrl)

Set URL

Parameters
string$sampleUrl
Returns
$this

Implements LinkInterface.

Definition at line 407 of file Link.php.

408  {
409  return $this->setData(self::KEY_SAMPLE_URL, $sampleUrl);
410  }

◆ setSortOrder()

setSortOrder (   $sortOrder)
Parameters
int$sortOrder
Returns
$this

Implements LinkInterface.

Definition at line 290 of file Link.php.

291  {
292  return $this->setData(self::KEY_SORT_ORDER, $sortOrder);
293  }

◆ setTitle()

setTitle (   $title)
Parameters
string$title
Returns
$this

Implements LinkInterface.

Definition at line 281 of file Link.php.

282  {
283  return $this->setData(self::KEY_TITLE, $title);
284  }
$title
Definition: default.phtml:14

Field Documentation

◆ KEY_IS_SHAREABLE

const KEY_IS_SHAREABLE = 'is_shareable'

Definition at line 42 of file Link.php.

◆ KEY_LINK_FILE

const KEY_LINK_FILE = 'link_file'

Definition at line 46 of file Link.php.

◆ KEY_LINK_FILE_CONTENT

const KEY_LINK_FILE_CONTENT = 'link_file_content'

Definition at line 47 of file Link.php.

◆ KEY_LINK_TYPE

const KEY_LINK_TYPE = 'link_type'

Definition at line 45 of file Link.php.

◆ KEY_LINK_URL

const KEY_LINK_URL = 'link_url'

Definition at line 48 of file Link.php.

◆ KEY_NUMBER_OF_DOWNLOADS

const KEY_NUMBER_OF_DOWNLOADS = 'number_of_downloads'

Definition at line 44 of file Link.php.

◆ KEY_PRICE

const KEY_PRICE = 'price'

Definition at line 43 of file Link.php.

◆ KEY_SAMPLE_FILE

const KEY_SAMPLE_FILE = 'sample_file'

Definition at line 50 of file Link.php.

◆ KEY_SAMPLE_FILE_CONTENT

const KEY_SAMPLE_FILE_CONTENT = 'sample_file_content'

Definition at line 51 of file Link.php.

◆ KEY_SAMPLE_TYPE

const KEY_SAMPLE_TYPE = 'sample_type'

Definition at line 49 of file Link.php.

◆ KEY_SAMPLE_URL

const KEY_SAMPLE_URL = 'sample_url'

Definition at line 52 of file Link.php.

◆ KEY_SORT_ORDER

const KEY_SORT_ORDER = 'sort_order'

Definition at line 41 of file Link.php.

◆ KEY_TITLE

const KEY_TITLE = 'title'

#+ Constants for field names

Definition at line 40 of file Link.php.

◆ LINK_SHAREABLE_CONFIG

const LINK_SHAREABLE_CONFIG = 2

Definition at line 35 of file Link.php.

◆ LINK_SHAREABLE_NO

const LINK_SHAREABLE_NO = 0

Definition at line 33 of file Link.php.

◆ LINK_SHAREABLE_YES

const LINK_SHAREABLE_YES = 1

Definition at line 31 of file Link.php.

◆ XML_PATH_CONFIG_IS_SHAREABLE

const XML_PATH_CONFIG_IS_SHAREABLE = 'catalog/downloadable/shareable'

Definition at line 29 of file Link.php.

◆ XML_PATH_DEFAULT_DOWNLOADS_NUMBER

const XML_PATH_DEFAULT_DOWNLOADS_NUMBER = 'catalog/downloadable/downloads_number'

Definition at line 25 of file Link.php.

◆ XML_PATH_LINKS_TITLE

const XML_PATH_LINKS_TITLE = 'catalog/downloadable/links_title'

Definition at line 23 of file Link.php.

◆ XML_PATH_TARGET_NEW_WINDOW

const XML_PATH_TARGET_NEW_WINDOW = 'catalog/downloadable/links_target_new_window'

Definition at line 27 of file Link.php.


The documentation for this class was generated from the following file: