_eavConfig = $eavConfig; parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data); $this->_storeManager = $storeManager; } /** * Actions after save * * @return $this */ public function afterSave() { $attribute = $this->_eavConfig->getAttribute('customer_address', 'street'); $value = $this->getValue(); switch ($this->getScope()) { case \Magento\Store\Model\ScopeInterface::SCOPE_WEBSITES: $website = $this->_storeManager->getWebsite($this->getScopeCode()); $attribute->setWebsite($website); $attribute->load($attribute->getId()); if ($attribute->getData('multiline_count') != $value) { $attribute->setData('scope_multiline_count', $value); } break; case ScopeConfigInterface::SCOPE_TYPE_DEFAULT: $attribute->setData('multiline_count', $value); break; } $attribute->save(); return parent::afterSave(); } /** * Processing object after delete data * * @return \Magento\Framework\Model\AbstractModel */ public function afterDelete() { $result = parent::afterDelete(); $attribute = $this->_eavConfig->getAttribute('customer_address', 'street'); switch ($this->getScope()) { case \Magento\Store\Model\ScopeInterface::SCOPE_WEBSITES: $website = $this->_storeManager->getWebsite($this->getScopeCode()); $attribute->setWebsite($website); $attribute->load($attribute->getId()); $attribute->setData('scope_multiline_count', null); break; case ScopeConfigInterface::SCOPE_TYPE_DEFAULT: $attribute->setData('multiline_count', 2); break; } $attribute->save(); return $result; } }