![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/magento/module-swatches/Model/ResourceModel/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace Magento\Swatches\Model\ResourceModel; /** * Swatch Resource Model * * @codeCoverageIgnore * @api * @since 100.0.2 */ class Swatch extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb { /** * Initialize resource model * * @return void */ protected function _construct() { $this->_init('eav_attribute_option_swatch', 'swatch_id'); } /** * Update default swatch option value. * * @param integer $id * @param string $defaultValue * @return void */ public function saveDefaultSwatchOption($id, $defaultValue) { if ($defaultValue !== null) { $bind = ['default_value' => $defaultValue]; $where = ['attribute_id = ?' => $id]; $this->getConnection()->update($this->getTable('eav_attribute'), $bind, $where); } } /** * Cleaned swatch option values when switching to dropdown input type. * * @param array $optionIDs * @param int $type * @throws \Magento\Framework\Exception\LocalizedException * @since 100.2.4 */ public function clearSwatchOptionByOptionIdAndType($optionIDs, $type = null) { if (count($optionIDs)) { foreach ($optionIDs as $optionId) { $where = ['option_id = ?' => $optionId]; if ($type !== null) { $where['type = ?'] = $type; } $this->getConnection()->delete($this->getMainTable(), $where); } } } }