Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Swatch.php
Go to the documentation of this file.
1 <?php
8 
16 {
22  protected function _construct()
23  {
24  $this->_init('eav_attribute_option_swatch', 'swatch_id');
25  }
26 
32  public function saveDefaultSwatchOption($id, $defaultValue)
33  {
34  if ($defaultValue !== null) {
35  $bind = ['default_value' => $defaultValue];
36  $where = ['attribute_id = ?' => $id];
37  $this->getConnection()->update($this->getTable('eav_attribute'), $bind, $where);
38  }
39  }
40 
49  public function clearSwatchOptionByOptionIdAndType($optionIDs, $type = null)
50  {
51  if (count($optionIDs)) {
52  foreach ($optionIDs as $optionId) {
53  $where = ['option_id' => $optionId];
54  if ($type !== null) {
55  $where['type = ?'] = $type;
56  }
57  $this->getConnection()->delete($this->getMainTable(), $where);
58  }
59  }
60  }
61 }
$id
Definition: fieldset.phtml:14
$type
Definition: item.phtml:13
clearSwatchOptionByOptionIdAndType($optionIDs, $type=null)
Definition: Swatch.php:49
saveDefaultSwatchOption($id, $defaultValue)
Definition: Swatch.php:32