@@ -146,7 +146,7 @@ public function execute($entityType, $entityData, $arguments = [])
146146 $ attributeTables [$ attribute ->getBackend ()->getTable ()][] = $ attribute ->getAttributeId ();
147147 $ attributesMap [$ attribute ->getAttributeId ()] = $ attribute ->getAttributeCode ();
148148 $ attributeScopeGlobal [$ attribute ->getAttributeId ()] =
149- $ attribute ->getIsGlobal () === ScopedAttributeInterface::SCOPE_GLOBAL ;
149+ $ attribute ->getIsGlobal () === ScopedAttributeInterface::SCOPE_GLOBAL ? 1 : 0 ;
150150 }
151151 }
152152 if (count ($ attributeTables )) {
@@ -180,13 +180,23 @@ public function execute($entityType, $entityData, $arguments = [])
180180 $ attributes = $ connection ->fetchAll ($ orderedUnionSelect );
181181 foreach ($ attributes as $ attributeValue ) {
182182 if (isset ($ attributesMap [$ attributeValue ['attribute_id ' ]])) {
183- if ($ attributeScopeGlobal [$ attributeValue ['attribute_id ' ]] &&
184- (int )$ attributeValue ['store_id ' ] !== Store::DEFAULT_STORE_ID
185- ) {
183+ $ isGlobalAttribute = $ attributeScopeGlobal [$ attributeValue ['attribute_id ' ]];
184+ $ storeId = $ attributeValue ['store_id ' ] ?? null ;
185+
186+ // Set global value if attribute scope is set to Global
187+ if ($ isGlobalAttribute && (int )$ storeId === Store::DEFAULT_STORE_ID ) {
188+ $ entityData [$ attributesMap [$ attributeValue ['attribute_id ' ]]] = $ attributeValue ['value ' ];
189+ continue ;
190+ }
191+
192+ if (!$ isGlobalAttribute && (int )$ storeId === Store::DEFAULT_STORE_ID ) {
186193 $ entityData [$ attributesMap [$ attributeValue ['attribute_id ' ]]] = $ attributeValue ['value ' ];
187194 continue ;
188195 }
189- $ entityData [$ attributesMap [$ attributeValue ['attribute_id ' ]]] = $ attributeValue ['value ' ];
196+
197+ if (!$ isGlobalAttribute && (int )$ storeId !== Store::DEFAULT_STORE_ID ) {
198+ $ entityData [$ attributesMap [$ attributeValue ['attribute_id ' ]]] = $ attributeValue ['value ' ];
199+ }
190200 } else {
191201 $ this ->logger ->warning (
192202 "Attempt to load value of nonexistent EAV attribute " ,
0 commit comments