* @category Diglin * @package Diglin * @copyright Copyright (c) Diglin (http://www.diglin.com) */ namespace MyNamespace\Catalog\Rewrite\Plugin; use Magento\Catalog\Model\ResourceModel\Eav\Attribute; /** * Class SwatchesEavAttribute * @package MyNamespace\Catalog\Rewrite\Plugin */ class SwatchesEavAttribute extends \Magento\Swatches\Model\Plugin\EavAttribute { /** * Set base data to Attribute * * @param Attribute $attribute * @return void */ public function beforeBeforeSave(Attribute $attribute) { // Move to logic to beforeSave Method } /** * @param \Magento\Catalog\Model\ResourceModel\Eav\Attribute $attribute */ public function beforeSave(Attribute $attribute) { if ($this->swatchHelper->isSwatchAttribute($attribute)) { $this->setProperOptionsArray($attribute); $this->validateOptions($attribute); $this->swatchHelper->assembleAdditionalDataEavAttribute($attribute); } $this->convertSwatchToDropdown($attribute); } /** * @param \Magento\Catalog\Model\ResourceModel\Eav\Attribute $attribute * * @return $this */ public function afterAfterSave(Attribute $attribute) { // Do nothing, move logic to method afterAfterCommitCallback } /** * @param \Magento\Catalog\Model\ResourceModel\Eav\Attribute $attribute */ public function afterAfterCommitCallback(Attribute $attribute) { if ($this->swatchHelper->isSwatchAttribute($attribute)) { $this->processSwatchOptions($attribute); $this->saveDefaultSwatchOptionValue($attribute); $this->saveSwatchParams($attribute); } } }