Skip to content

Commit 1f743bd

Browse files
committed
MAGETWO-91559: Static blocks with same ID appear in place of correct block
1 parent e8fda7c commit 1f743bd

File tree

1 file changed

+11
-6
lines changed
  • app/code/Magento/Cms/Model/ResourceModel

1 file changed

+11
-6
lines changed

app/code/Magento/Cms/Model/ResourceModel/Block.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,12 @@ public function getIsUniqueBlockToStores(AbstractModel $object)
183183
$entityMetadata = $this->metadataPool->getMetadata(BlockInterface::class);
184184
$linkField = $entityMetadata->getLinkField();
185185

186-
if ($this->_storeManager->isSingleStoreMode()) {
187-
$stores = [Store::DEFAULT_STORE_ID];
188-
} else {
189-
$stores = (array)$object->getData('store_id');
186+
$stores = (array)$object->getData('store_id');
187+
$isDefaultStore = $this->_storeManager->isSingleStoreMode()
188+
|| array_search(Store::DEFAULT_STORE_ID, $stores) !== false;
189+
190+
if(!$isDefaultStore) {
191+
$stores[] = Store::DEFAULT_STORE_ID;
190192
}
191193

192194
$select = $this->getConnection()->select()
@@ -196,8 +198,11 @@ public function getIsUniqueBlockToStores(AbstractModel $object)
196198
'cb.' . $linkField . ' = cbs.' . $linkField,
197199
[]
198200
)
199-
->where('cb.identifier = ?', $object->getData('identifier'))
200-
->where('cbs.store_id IN (?)', $stores);
201+
->where('cb.identifier = ? ', $object->getData('identifier'));
202+
203+
if(!$isDefaultStore) {
204+
$select->where('cbs.store_id IN (?)', $stores);
205+
}
201206

202207
if ($object->getId()) {
203208
$select->where('cb.' . $entityMetadata->getIdentifierField() . ' <> ?', $object->getId());

0 commit comments

Comments
 (0)