Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Option.php
Go to the documentation of this file.
1 <?php
7 
20  \Magento\Catalog\Model\Product\Configuration\Item\Option\OptionInterface
21 {
25  protected $_item;
26 
30  protected $_product;
31 
37  protected function _construct()
38  {
39  $this->_init(\Magento\Quote\Model\ResourceModel\Quote\Item\Option::class);
40  }
41 
47  protected function _hasModelChanged()
48  {
49  if (!$this->hasDataChanges()) {
50  return false;
51  }
52 
53  return $this->_getResource()->hasDataChanged($this);
54  }
55 
62  public function setItem($item)
63  {
64  $this->setItemId($item->getId());
65  $this->_item = $item;
66  return $this;
67  }
68 
74  public function getItem()
75  {
76  return $this->_item;
77  }
78 
85  public function setProduct($product)
86  {
87  $this->setProductId($product->getId());
88  $this->_product = $product;
89  return $this;
90  }
91 
97  public function getProduct()
98  {
99  return $this->_product;
100  }
101 
107  public function getValue()
108  {
109  return $this->_getData('value');
110  }
111 
117  public function beforeSave()
118  {
119  if ($this->getItem()) {
120  $this->setItemId($this->getItem()->getId());
121  }
122  return parent::beforeSave();
123  }
124 
130  public function __clone()
131  {
132  $this->setId(null);
133  $this->_item = null;
134  return $this;
135  }
136 }