resourceConfig = $resourceConfig; $this->attributeFactory = $attributeFactory; parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data); } /** * Update the default product tax class * * @return $this */ public function afterSave() { $attributeCode = "tax_class_id"; $attribute = $this->attributeFactory->create(); $attribute->loadByCode(\Magento\Catalog\Model\Product::ENTITY, $attributeCode); if (!$attribute->getId()) { throw new \Magento\Framework\Exception\LocalizedException(__('Invalid attribute %1', $attributeCode)); } $attribute->setData("default_value", $this->getData('value')); $attribute->save(); return parent::afterSave(); } }