Skip to content

Commit c8baed5

Browse files
MC-30963: [Magento Cloud] CMS blocks with identical identifiers
1 parent 606c3e8 commit c8baed5

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

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

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -185,13 +185,9 @@ public function getIsUniqueBlockToStores(AbstractModel $object)
185185
$entityMetadata = $this->metadataPool->getMetadata(BlockInterface::class);
186186
$linkField = $entityMetadata->getLinkField();
187187

188-
$stores = (array)$object->getData('store_id');
189-
$isDefaultStore = $this->_storeManager->isSingleStoreMode()
190-
|| array_search(Store::DEFAULT_STORE_ID, $stores) !== false;
191-
192-
if (!$isDefaultStore) {
193-
$stores[] = Store::DEFAULT_STORE_ID;
194-
}
188+
$stores = $this->_storeManager->isSingleStoreMode()
189+
? [Store::DEFAULT_STORE_ID]
190+
: (array)$object->getData('store_id');
195191

196192
$select = $this->getConnection()->select()
197193
->from(['cb' => $this->getMainTable()])
@@ -200,11 +196,8 @@ public function getIsUniqueBlockToStores(AbstractModel $object)
200196
'cb.' . $linkField . ' = cbs.' . $linkField,
201197
[]
202198
)
203-
->where('cb.identifier = ? ', $object->getData('identifier'));
204-
205-
if (!$isDefaultStore) {
206-
$select->where('cbs.store_id IN (?)', $stores);
207-
}
199+
->where('cb.identifier = ? ', $object->getData('identifier'))
200+
->where('cbs.store_id IN (?)', $stores);
208201

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

app/code/Magento/Cms/Test/Mftf/Test/CheckStaticBlocksTest.xml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,23 @@
5656
<seeInCurrentUrl url="cms/block/new" stepKey="VerifyNewBlockPageIsOpened1"/>
5757
<!--Add new BLock with the same data-->
5858
<actionGroup ref="FillOutBlockContent" stepKey="FillOutBlockContent1"/>
59-
<selectOption selector="{{BlockNewPageBasicFieldsSection.storeView}}" userInput="Default Store View" stepKey="selectDefaultStoreView" />
60-
<selectOption selector="{{BlockNewPageBasicFieldsSection.storeView}}" userInput="{{customStore.name}}" stepKey="selectSecondStoreView1" />
6159
<click selector="{{BlockNewPagePageActionsSection.saveBlock}}" stepKey="ClickToSaveBlock1"/>
6260
<waitForPageLoad stepKey="waitForPageLoad6"/>
6361
<!--Verify that corresponding message is displayed-->
6462
<see userInput="A block identifier with the same properties already exists in the selected store." stepKey="VerifyBlockIsSaved1"/>
63+
<!--Click to go back and add new block-->
64+
<click selector="{{BlockNewPagePageActionsSection.back}}" stepKey="ClickToGoBack1"/>
65+
<waitForPageLoad stepKey="waitForPageLoad7"/>
66+
<click selector="{{BlockPageActionsSection.addNewBlock}}" stepKey="ClickToAddNewBlock2"/>
67+
<waitForPageLoad stepKey="waitForPageLoad8"/>
68+
<seeInCurrentUrl url="cms/block/new" stepKey="VerifyNewBlockPageIsOpened2"/>
69+
<!--Add new BLock with the same data for another store view-->
70+
<actionGroup ref="FillOutBlockContent" stepKey="FillOutBlockContent2"/>
71+
<selectOption selector="{{BlockNewPageBasicFieldsSection.storeView}}" userInput="Default Store View" stepKey="selectDefaultStoreView" />
72+
<selectOption selector="{{BlockNewPageBasicFieldsSection.storeView}}" userInput="{{customStore.name}}" stepKey="selectSecondStoreView1" />
73+
<click selector="{{BlockNewPagePageActionsSection.saveBlock}}" stepKey="ClickToSaveBlock2"/>
74+
<waitForPageLoad stepKey="waitForPageLoad9"/>
75+
<see userInput="You saved the block." stepKey="VerifyBlockIsSaved2"/>
6576

6677
<after>
6778
<actionGroup ref="AdminDeleteWebsiteActionGroup" stepKey="DeleteWebsite">

0 commit comments

Comments
 (0)