|
8 | 8 |
|
9 | 9 | use Magento\Eav\Model\Attribute;
|
10 | 10 | use Magento\Eav\Model\AttributeDataFactory;
|
| 11 | +use Magento\Eav\Model\Config; |
11 | 12 | use Magento\Framework\DataObject;
|
12 | 13 |
|
13 | 14 | /**
|
@@ -47,14 +48,22 @@ class Data extends \Magento\Framework\Validator\AbstractValidator
|
47 | 48 | */
|
48 | 49 | private $ignoredAttributesByTypesList;
|
49 | 50 |
|
| 51 | + /** |
| 52 | + * @var \Magento\Eav\Model\Config |
| 53 | + */ |
| 54 | + private $eavConfig; |
| 55 | + |
50 | 56 | /**
|
51 | 57 | * @param AttributeDataFactory $attrDataFactory
|
52 | 58 | * @param array $ignoredAttributesByTypesList
|
53 | 59 | */
|
54 | 60 | public function __construct(
|
55 | 61 | AttributeDataFactory $attrDataFactory,
|
| 62 | + Config $eavConfig = null, |
56 | 63 | array $ignoredAttributesByTypesList = []
|
57 | 64 | ) {
|
| 65 | + $this->eavConfig = $eavConfig ?: \Magento\Framework\App\ObjectManager::getInstance() |
| 66 | + ->get(Config::class); |
58 | 67 | $this->_attrDataFactory = $attrDataFactory;
|
59 | 68 | $this->ignoredAttributesByTypesList = $ignoredAttributesByTypesList;
|
60 | 69 | }
|
@@ -166,8 +175,9 @@ protected function _getAttributes($entity)
|
166 | 175 | } elseif ($entity instanceof \Magento\Framework\Model\AbstractModel &&
|
167 | 176 | $entity->getResource() instanceof \Magento\Eav\Model\Entity\AbstractEntity
|
168 | 177 | ) { // $entity is EAV-model
|
| 178 | + $type = $entity->getEntityType()->getEntityTypeCode(); |
169 | 179 | /** @var \Magento\Eav\Model\Entity\Type $entityType */
|
170 |
| - $entityType = $entity->getEntityType(); |
| 180 | + $entityType = $this->eavConfig->getEntityType($type); |
171 | 181 | $attributes = $entityType->getAttributeCollection()->getItems();
|
172 | 182 |
|
173 | 183 | $ignoredTypeAttributes = $this->ignoredAttributesByTypesList[$entityType->getEntityTypeCode()] ?? [];
|
|
0 commit comments