Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
module-swatches
Model
ResourceModel
Swatch.php
Go to the documentation of this file.
1
<?php
7
namespace
Magento\Swatches\Model\ResourceModel
;
8
15
class
Swatch
extends
\Magento\Framework\Model\ResourceModel\Db\AbstractDb
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
}
Magento\Framework\Model\ResourceModel\Db\AbstractDb\getMainTable
getMainTable()
Definition:
AbstractDb.php:264
Magento\Swatches\Model\ResourceModel\Swatch
Definition:
Swatch.php:15
$id
$id
Definition:
fieldset.phtml:14
Magento\Framework\Model\ResourceModel\Db\AbstractDb\_init
_init($mainTable, $idFieldName)
Definition:
AbstractDb.php:186
Magento\Swatches\Model\ResourceModel\Swatch\_construct
_construct()
Definition:
Swatch.php:22
$type
$type
Definition:
item.phtml:13
Magento\Swatches\Model\ResourceModel\Swatch\clearSwatchOptionByOptionIdAndType
clearSwatchOptionByOptionIdAndType($optionIDs, $type=null)
Definition:
Swatch.php:49
Magento\Framework\Model\ResourceModel\Db\AbstractDb\getTable
getTable($tableName)
Definition:
AbstractDb.php:279
Magento\Framework\Model\ResourceModel\Db\AbstractDb
Definition:
AbstractDb.php:24
Magento\Swatches\Model\ResourceModel
$optionId
$optionId
Definition:
product_with_custom_option.php:53
Magento\Swatches\Model\ResourceModel\Swatch\saveDefaultSwatchOption
saveDefaultSwatchOption($id, $defaultValue)
Definition:
Swatch.php:32
Magento\Framework\Model\ResourceModel\Db\AbstractDb\getConnection
getConnection()
Definition:
AbstractDb.php:325