51 $this->attrLockValidator = $lockValidator;
64 $applyTo = $object->getApplyTo();
65 if (is_array($applyTo)) {
66 $object->setApplyTo(implode(
',', $applyTo));
68 return parent::_beforeSave($object);
80 return parent::_afterSave($object);
91 $origData = $object->getOrigData();
93 if ($object->isScopeGlobal() && isset(
94 $origData[
'is_global']
95 ) && \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL != $origData[
'is_global']
97 $attributeStoreIds = array_keys($this->_storeManager->getStores());
98 if (!empty($attributeStoreIds)) {
100 'attribute_id = ?' => $object->getId(),
101 'store_id IN(?)' => $attributeStoreIds,
103 $this->
getConnection()->delete($object->getBackendTable(), $delCondition);
119 if (!$object->getEntityAttributeId()) {
126 $object->getEntityTypeId(),
133 throw new \Magento\Framework\Exception\LocalizedException(
134 __(
'Attribute \'%1\' is locked. %2',
$attribute->getAttributeCode(), $exception->getMessage())
138 $backendTable =
$attribute->getBackend()->getTable();
140 $linkField = $this->getMetadataPool()
141 ->getMetadata(ProductInterface::class)
144 $backendLinkField =
$attribute->getBackend()->getEntityIdField();
147 ->from([
'b' => $backendTable])
149 [
'e' =>
$attribute->getEntity()->getEntityTable()],
150 "b.$backendLinkField = e.$linkField" 151 )->where(
'b.attribute_id = ?',
$attribute->getId())
152 ->where(
'e.attribute_set_id = ?',
$result[
'attribute_set_id']);
158 $condition = [
'entity_attribute_id = ?' => $object->getEntityAttributeId()];
167 private function getMetadataPool()
169 if (
null === $this->metadataPool) {
deleteEntity(\Magento\Framework\Model\AbstractModel $object)
__construct(\Magento\Framework\Model\ResourceModel\Db\Context $context, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Eav\Model\ResourceModel\Entity\Type $eavEntityType, \Magento\Eav\Model\Config $eavConfig, LockValidatorInterface $lockValidator, $connectionName=null)
_afterSave(\Magento\Framework\Model\AbstractModel $object)
_beforeSave(\Magento\Framework\Model\AbstractModel $object)
_clearUselessAttributeValues(\Magento\Framework\Model\AbstractModel $object)
getEntityAttribute($entityAttributeId)