diff --git a/app/code/Magento/Catalog/Model/ResourceModel/AbstractResource.php b/app/code/Magento/Catalog/Model/ResourceModel/AbstractResource.php
index 6614b10ef609e..1e55bd35553ab 100644
--- a/app/code/Magento/Catalog/Model/ResourceModel/AbstractResource.php
+++ b/app/code/Magento/Catalog/Model/ResourceModel/AbstractResource.php
@@ -9,10 +9,6 @@
namespace Magento\Catalog\Model\ResourceModel;
use Magento\Eav\Model\Entity\Attribute\AbstractAttribute;
-use Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend;
-use Magento\Eav\Model\Entity\Attribute\Frontend\AbstractFrontend;
-use Magento\Eav\Model\Entity\Attribute\Source\AbstractSource;
-use Magento\Eav\Model\Entity\Attribute\UniqueValidationInterface;
/**
* Catalog entity abstract model
@@ -43,18 +39,16 @@ abstract class AbstractResource extends \Magento\Eav\Model\Entity\AbstractEntity
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Catalog\Model\Factory $modelFactory
* @param array $data
- * @param UniqueValidationInterface|null $uniqueValidator
*/
public function __construct(
\Magento\Eav\Model\Entity\Context $context,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Catalog\Model\Factory $modelFactory,
- $data = [],
- UniqueValidationInterface $uniqueValidator = null
+ $data = []
) {
$this->_storeManager = $storeManager;
$this->_modelFactory = $modelFactory;
- parent::__construct($context, $data, $uniqueValidator);
+ parent::__construct($context, $data);
}
/**
@@ -94,7 +88,7 @@ protected function _isApplicableAttribute($object, $attribute)
/**
* Check whether attribute instance (attribute, backend, frontend or source) has method and applicable
*
- * @param AbstractAttribute|AbstractBackend|AbstractFrontend|AbstractSource $instance
+ * @param AbstractAttribute|\Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend|\Magento\Eav\Model\Entity\Attribute\Frontend\AbstractFrontend|\Magento\Eav\Model\Entity\Attribute\Source\AbstractSource $instance
* @param string $method
* @param array $args array of arguments
* @return boolean
diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product.php b/app/code/Magento/Catalog/Model/ResourceModel/Product.php
index e438e2f54113d..95f09c7ee80be 100644
--- a/app/code/Magento/Catalog/Model/ResourceModel/Product.php
+++ b/app/code/Magento/Catalog/Model/ResourceModel/Product.php
@@ -8,7 +8,6 @@
use Magento\Catalog\Model\ResourceModel\Product\Website\Link as ProductWebsiteLink;
use Magento\Framework\App\ObjectManager;
use Magento\Catalog\Model\Indexer\Category\Product\TableMaintainer;
-use Magento\Eav\Model\Entity\Attribute\UniqueValidationInterface;
/**
* Product entity resource model
@@ -102,7 +101,6 @@ class Product extends AbstractResource
* @param \Magento\Catalog\Model\Product\Attribute\DefaultAttributes $defaultAttributes
* @param array $data
* @param TableMaintainer|null $tableMaintainer
- * @param UniqueValidationInterface|null $uniqueValidator
*
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
@@ -117,8 +115,7 @@ public function __construct(
\Magento\Eav\Model\Entity\TypeFactory $typeFactory,
\Magento\Catalog\Model\Product\Attribute\DefaultAttributes $defaultAttributes,
$data = [],
- TableMaintainer $tableMaintainer = null,
- UniqueValidationInterface $uniqueValidator = null
+ TableMaintainer $tableMaintainer = null
) {
$this->_categoryCollectionFactory = $categoryCollectionFactory;
$this->_catalogCategory = $catalogCategory;
@@ -130,8 +127,7 @@ public function __construct(
$context,
$storeManager,
$modelFactory,
- $data,
- $uniqueValidator
+ $data
);
$this->connectionName = 'catalog';
$this->tableMaintainer = $tableMaintainer ?: ObjectManager::getInstance()->get(TableMaintainer::class);
@@ -661,7 +657,7 @@ public function save(\Magento\Framework\Model\AbstractModel $object)
}
/**
- * Retrieve entity manager object.
+ * Retrieve entity manager object
*
* @return \Magento\Framework\EntityManager\EntityManager
*/
@@ -675,7 +671,7 @@ private function getEntityManager()
}
/**
- * Retrieve ProductWebsiteLink object.
+ * Retrieve ProductWebsiteLink object
*
* @deprecated 101.1.0
* @return ProductWebsiteLink
@@ -686,7 +682,7 @@ private function getProductWebsiteLink()
}
/**
- * Retrieve CategoryLink object.
+ * Retrieve CategoryLink object
*
* @deprecated 101.1.0
* @return \Magento\Catalog\Model\ResourceModel\Product\CategoryLink
@@ -702,7 +698,6 @@ private function getProductCategoryLink()
/**
* Extends parent method to be appropriate for product.
- *
* Store id is required to correctly identify attribute value we are working with.
*
* @inheritdoc
diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCheckingAttributeValueOnProductEditPageTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCheckingAttributeValueOnProductEditPageTest.xml
index 59ac446d7a608..bd49f643148d9 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCheckingAttributeValueOnProductEditPageTest.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCheckingAttributeValueOnProductEditPageTest.xml
@@ -52,6 +52,7 @@
+
diff --git a/app/code/Magento/Eav/Model/Entity/AbstractEntity.php b/app/code/Magento/Eav/Model/Entity/AbstractEntity.php
index 7f6734b8b6b60..9b7abde37cc19 100644
--- a/app/code/Magento/Eav/Model/Entity/AbstractEntity.php
+++ b/app/code/Magento/Eav/Model/Entity/AbstractEntity.php
@@ -12,7 +12,6 @@
use Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend;
use Magento\Eav\Model\Entity\Attribute\Frontend\AbstractFrontend;
use Magento\Eav\Model\Entity\Attribute\Source\AbstractSource;
-use Magento\Eav\Model\Entity\Attribute\UniqueValidationInterface;
use Magento\Framework\App\Config\Element;
use Magento\Framework\DataObject;
use Magento\Framework\DB\Adapter\DuplicateException;
@@ -218,21 +217,12 @@ abstract class AbstractEntity extends AbstractResource implements EntityInterfac
*/
protected $objectRelationProcessor;
- /**
- * @var UniqueValidationInterface
- */
- private $uniqueValidator;
-
/**
* @param Context $context
* @param array $data
- * @param UniqueValidationInterface|null $uniqueValidator
*/
- public function __construct(
- Context $context,
- $data = [],
- UniqueValidationInterface $uniqueValidator = null
- ) {
+ public function __construct(Context $context, $data = [])
+ {
$this->_eavConfig = $context->getEavConfig();
$this->_resource = $context->getResource();
$this->_attrSetEntity = $context->getAttributeSetEntity();
@@ -241,8 +231,6 @@ public function __construct(
$this->_universalFactory = $context->getUniversalFactory();
$this->transactionManager = $context->getTransactionManager();
$this->objectRelationProcessor = $context->getObjectRelationProcessor();
- $this->uniqueValidator = $uniqueValidator ?:
- ObjectManager::getInstance()->get(UniqueValidationInterface::class);
parent::__construct();
$properties = get_object_vars($this);
foreach ($data as $key => $value) {
@@ -511,7 +499,6 @@ public function addAttributeByScope(AbstractAttribute $attribute, $entity = null
/**
* Get attributes by scope
*
- * @param string $suffix
* @return array
*/
private function getAttributesByScope($suffix)
@@ -982,8 +969,12 @@ public function checkAttributeUniqueValue(AbstractAttribute $attribute, $object)
$data = $connection->fetchCol($select, $bind);
- if ($object->getData($entityIdField)) {
- return $this->uniqueValidator->validate($attribute, $object, $this, $entityIdField, $data);
+ $objectId = $object->getData($entityIdField);
+ if ($objectId) {
+ if (isset($data[0])) {
+ return $data[0] == $objectId;
+ }
+ return true;
}
return !count($data);
@@ -1995,7 +1986,6 @@ public function afterDelete(DataObject $object)
/**
* Load attributes for object
- *
* If the object will not pass all attributes for this entity type will be loaded
*
* @param array $attributes
diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/UniqueValidationInterface.php b/app/code/Magento/Eav/Model/Entity/Attribute/UniqueValidationInterface.php
deleted file mode 100644
index 50a6ff9329fc9..0000000000000
--- a/app/code/Magento/Eav/Model/Entity/Attribute/UniqueValidationInterface.php
+++ /dev/null
@@ -1,35 +0,0 @@
-getData($entityLinkField);
- }
-
- return true;
- }
-}
diff --git a/app/code/Magento/Eav/etc/di.xml b/app/code/Magento/Eav/etc/di.xml
index 92c1ef11b9c1f..c8afd10aa3eee 100644
--- a/app/code/Magento/Eav/etc/di.xml
+++ b/app/code/Magento/Eav/etc/di.xml
@@ -8,7 +8,6 @@
-