Purchased.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Downloadable\Model\Link;
  7. /**
  8. * Downloadable links purchased model
  9. *
  10. * @api
  11. * @method int getOrderId()
  12. * @method \Magento\Downloadable\Model\Link\Purchased setOrderId(int $value)
  13. * @method string getOrderIncrementId()
  14. * @method \Magento\Downloadable\Model\Link\Purchased setOrderIncrementId(string $value)
  15. * @method int getOrderItemId()
  16. * @method \Magento\Downloadable\Model\Link\Purchased setOrderItemId(int $value)
  17. * @method string getCreatedAt()
  18. * @method \Magento\Downloadable\Model\Link\Purchased setCreatedAt(string $value)
  19. * @method string getUpdatedAt()
  20. * @method \Magento\Downloadable\Model\Link\Purchased setUpdatedAt(string $value)
  21. * @method int getCustomerId()
  22. * @method \Magento\Downloadable\Model\Link\Purchased setCustomerId(int $value)
  23. * @method string getProductName()
  24. * @method \Magento\Downloadable\Model\Link\Purchased setProductName(string $value)
  25. * @method string getSku()
  26. * @method \Magento\Downloadable\Model\Link\Purchased setSku(string $value)
  27. * @method string getLinkSectionTitle()
  28. * @method \Magento\Downloadable\Model\Link\Purchased setLinkSectionTitle(string $value)
  29. *
  30. * @api
  31. * @since 100.0.2
  32. */
  33. class Purchased extends \Magento\Framework\Model\AbstractModel
  34. {
  35. /**
  36. * Enter description here...
  37. *
  38. * @return void
  39. */
  40. protected function _construct()
  41. {
  42. $this->_init(\Magento\Downloadable\Model\ResourceModel\Link\Purchased::class);
  43. parent::_construct();
  44. }
  45. /**
  46. * Check order id
  47. *
  48. * @return $this
  49. */
  50. public function beforeSave()
  51. {
  52. if (null == $this->getOrderId()) {
  53. throw new \Exception(__('Order id cannot be null'));
  54. }
  55. return parent::beforeSave();
  56. }
  57. }