Skip to content

Commit 141ad08

Browse files
committed
ACP2E-675: Telephone required on all websites when set to be optional on some
1 parent 0768a9f commit 141ad08

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

app/code/Magento/Eav/Model/Config.php

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -473,17 +473,19 @@ protected function _initAttributes($entityType)
473473
return $this;
474474
}
475475

476-
if ($this->initAttributesFromCache($entityType)) {
476+
$entityTypeCode = $entityType->getEntityTypeCode();
477+
$attributes = $this->_universalFactory->create($entityType->getEntityAttributeCollection());
478+
$websiteId = $attributes instanceof Collection ? $this->getWebsiteId($attributes) : 0;
479+
$cacheKey = self::ATTRIBUTES_CACHE_ID . '-' . $entityTypeCode . '-' . $websiteId ;
480+
481+
if ($this->isCacheEnabled() && $this->initAttributesFromCache($entityType, $cacheKey)) {
477482
return $this;
478483
}
479484

480485
\Magento\Framework\Profiler::start('EAV: ' . __METHOD__, ['group' => 'EAV', 'method' => __METHOD__]);
481486

482-
$attributes = $this->_universalFactory->create(
483-
$entityType->getEntityAttributeCollection()
484-
)->setEntityTypeFilter(
485-
$entityType
486-
)->getData();
487+
$attributes = $attributes->setEntityTypeFilter($entityType)
488+
->getData();
487489

488490
$this->_attributeData[$entityTypeCode] = [];
489491
foreach ($attributes as $attribute) {
@@ -497,7 +499,7 @@ protected function _initAttributes($entityType)
497499
if ($this->isCacheEnabled()) {
498500
$this->_cache->save(
499501
$this->serializer->serialize($this->_attributeData[$entityTypeCode]),
500-
self::ATTRIBUTES_CACHE_ID . $entityTypeCode,
502+
$cacheKey,
501503
[
502504
\Magento\Eav\Model\Cache\Type::CACHE_TAG,
503505
\Magento\Eav\Model\Entity\Attribute::CACHE_TAG
@@ -949,15 +951,14 @@ private function setAttributeData($attribute, $entityType): AbstractAttribute
949951
* Initialize attributes from cache for given entity type
950952
*
951953
* @param Type $entityType
954+
* @param string $cacheKey
952955
* @return bool
953956
*/
954-
private function initAttributesFromCache(Type $entityType)
957+
private function initAttributesFromCache(Type $entityType, string $cacheKey)
955958
{
956959
$entityTypeCode = $entityType->getEntityTypeCode();
957-
$attributeCollection = $this->_universalFactory->create($entityType->getEntityAttributeCollection());
958-
$websiteId = $attributeCollection instanceof Collection ? $this->getWebsiteId($attributeCollection) : 0;
959-
$cacheKey = self::ATTRIBUTES_CACHE_ID . '-' . $entityTypeCode . '-' . $websiteId ;
960-
if ($this->isCacheEnabled() && ($attributes = $this->_cache->load($cacheKey))) {
960+
$attributes = $this->_cache->load($cacheKey);
961+
if ($attributes) {
961962
$attributes = $this->serializer->unserialize($attributes);
962963
if ($attributes) {
963964
foreach ($attributes as $attribute) {

0 commit comments

Comments
 (0)