1212use Magento \Catalog \Model \Product \Attribute \Backend \Media \EntryConverterPool ;
1313use Magento \Framework \Api \AttributeValueFactory ;
1414use Magento \Framework \App \Filesystem \DirectoryList ;
15+ use Magento \Framework \App \ObjectManager ;
1516use Magento \Framework \DataObject \IdentityInterface ;
1617use Magento \Framework \Pricing \SaleableInterface ;
1718
@@ -346,6 +347,11 @@ class Product extends \Magento\Catalog\Model\AbstractModel implements
346347 */
347348 protected $ linkTypeProvider ;
348349
350+ /**
351+ * @var \Magento\Eav\Model\Config|null
352+ */
353+ private $ eavConfig ;
354+
349355 /**
350356 * Product constructor.
351357 * @param \Magento\Framework\Model\Context $context
@@ -384,6 +390,7 @@ class Product extends \Magento\Catalog\Model\AbstractModel implements
384390 * @param \Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface $joinProcessor
385391 * @param array $data
386392 *
393+ * @param \Magento\Eav\Model\Config|null $config
387394 * @SuppressWarnings(PHPMD.ExcessiveParameterList)
388395 * @SuppressWarnings(PHPMD.UnusedFormalParameter)
389396 */
@@ -422,7 +429,8 @@ public function __construct(
422429 EntryConverterPool $ mediaGalleryEntryConverterPool ,
423430 \Magento \Framework \Api \DataObjectHelper $ dataObjectHelper ,
424431 \Magento \Framework \Api \ExtensionAttribute \JoinProcessorInterface $ joinProcessor ,
425- array $ data = []
432+ array $ data = [],
433+ \Magento \Eav \Model \Config $ config = null
426434 ) {
427435 $ this ->metadataService = $ metadataService ;
428436 $ this ->_itemOptionFactory = $ itemOptionFactory ;
@@ -461,6 +469,7 @@ public function __construct(
461469 $ resourceCollection ,
462470 $ data
463471 );
472+ $ this ->eavConfig = $ config ?? ObjectManager::getInstance ()->get (\Magento \Eav \Model \Config::class);
464473 }
465474
466475 /**
@@ -479,7 +488,10 @@ protected function _construct()
479488 protected function getCustomAttributesCodes ()
480489 {
481490 if ($ this ->customAttributesCodes === null ) {
482- $ this ->customAttributesCodes = $ this ->getEavAttributesCodes ($ this ->metadataService );
491+ $ this ->customAttributesCodes = array_keys ($ this ->eavConfig ->getEntityAttributes (
492+ self ::ENTITY ,
493+ $ this
494+ ));
483495 $ this ->customAttributesCodes = array_diff ($ this ->customAttributesCodes , $ this ->interfaceAttributes );
484496 }
485497 return $ this ->customAttributesCodes ;
0 commit comments