From 32ed6410267f7bf5ea1c5d81cb663b2cc3981768 Mon Sep 17 00:00:00 2001 From: Vova Yatsyuk Date: Fri, 14 Jun 2019 10:13:57 +0300 Subject: [PATCH] Fix cms block save for specified store view, when another block with same ID is saved for 'All Store Views'. --- .../Magento/Cms/Model/ResourceModel/Block.php | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/app/code/Magento/Cms/Model/ResourceModel/Block.php b/app/code/Magento/Cms/Model/ResourceModel/Block.php index 30e817713755c..0aec9c35619bc 100644 --- a/app/code/Magento/Cms/Model/ResourceModel/Block.php +++ b/app/code/Magento/Cms/Model/ResourceModel/Block.php @@ -185,12 +185,10 @@ public function getIsUniqueBlockToStores(AbstractModel $object) $entityMetadata = $this->metadataPool->getMetadata(BlockInterface::class); $linkField = $entityMetadata->getLinkField(); - $stores = (array)$object->getData('store_id'); - $isDefaultStore = $this->_storeManager->isSingleStoreMode() - || array_search(Store::DEFAULT_STORE_ID, $stores) !== false; - - if (!$isDefaultStore) { - $stores[] = Store::DEFAULT_STORE_ID; + if ($this->_storeManager->isSingleStoreMode()) { + $stores = [Store::DEFAULT_STORE_ID]; + } else { + $stores = (array)$object->getData('store_id'); } $select = $this->getConnection()->select() @@ -200,11 +198,8 @@ public function getIsUniqueBlockToStores(AbstractModel $object) 'cb.' . $linkField . ' = cbs.' . $linkField, [] ) - ->where('cb.identifier = ? ', $object->getData('identifier')); - - if (!$isDefaultStore) { - $select->where('cbs.store_id IN (?)', $stores); - } + ->where('cb.identifier = ?', $object->getData('identifier')) + ->where('cbs.store_id IN (?)', $stores); if ($object->getId()) { $select->where('cb.' . $entityMetadata->getIdentifierField() . ' <> ?', $object->getId());