Code.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\GoogleOptimizer\Model;
  7. /**
  8. * Google Experiment Code model
  9. *
  10. * @method \Magento\GoogleOptimizer\Model\Code setEntityId(int $value)
  11. * @method string getEntityId()
  12. * @method \Magento\GoogleOptimizer\Model\Code setEntityType(string $value)
  13. * @method string getEntityType()
  14. * @method \Magento\GoogleOptimizer\Model\Code setStoreId(int $value)
  15. * @method int getStoreId()
  16. * @method \Magento\GoogleOptimizer\Model\Code setExperimentScript(int $value)
  17. * @method string getExperimentScript()
  18. * @api
  19. * @since 100.0.2
  20. */
  21. class Code extends \Magento\Framework\Model\AbstractModel
  22. {
  23. /**#@+
  24. * Entity types
  25. */
  26. const ENTITY_TYPE_PRODUCT = 'product';
  27. const ENTITY_TYPE_CATEGORY = 'category';
  28. const ENTITY_TYPE_PAGE = 'cms';
  29. /**#@-*/
  30. /**#@-*/
  31. protected $_validateEntryFlag = false;
  32. /**
  33. * Model construct that should be used for object initialization
  34. * @return void
  35. */
  36. protected function _construct()
  37. {
  38. parent::_construct();
  39. $this->_init(\Magento\GoogleOptimizer\Model\ResourceModel\Code::class);
  40. }
  41. /**
  42. * Loading by entity id and type type
  43. *
  44. * @param int $entityId
  45. * @param string $entityType One of self::CODE_ENTITY_TYPE_
  46. * @param int $storeId
  47. * @return $this
  48. */
  49. public function loadByEntityIdAndType($entityId, $entityType, $storeId = 0)
  50. {
  51. $this->getResource()->loadByEntityType($this, $entityId, $entityType, $storeId);
  52. $this->_afterLoad();
  53. return $this;
  54. }
  55. }