magento2: Inconsistent cms block validation and save methods
Additional information
The issue was reopened on 16 July 2019. The reopening reason is that current behavior(after fixes) brings new issues. See comment for details
- Currently, I have to re-save an existing block (select every store view except one manually) and only after that, I can finally create a block for a specific store view.
- Previously, I could add a new block and it just works. Magento correctly used the fallback mechanism to show the correct block at every store view.
Additionally, when using a new approach, if I’ll create a new store view I have to open cms block again and select newly created store view in store views combo box. Previously all work flawlessly because I always had a default block saved with “All store views” selected.
Preconditions
Magento develop branch
Steps to reproduce
- Install Magento from
developbranch. - Make sure that you have only one store view and
SingleStoreModeoption in disabled - Create cms block
exampleforAll Store views - Create another cms block
examplefor first store view only
Expected result
- Block should be saved for selected store view
Actual result
-
An exception will be thrown:
A block identifier with the same properties already exists in the selected store.
Propose
Validator should validate actual block data, so we can remove the following check completely:
if ($this->_storeManager->hasSingleStore()) {
$stores = [Store::DEFAULT_STORE_ID];
}
OR
this logic should be moved to _beforeSave and slightly modified, to check SingleStoreMode option:
if ($this->_storeManager->getSingleStoreMode()) {
$object->setData('stores', [Store::DEFAULT_STORE_ID]);
}
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 2
- Comments: 19 (15 by maintainers)
Commits related to this issue
- MAGETWO-91559: Static blocks with same ID appear in place of correct block — committed to magento/magento2 by mcahriman 6 years ago
Hello @vovayatsyuk
Thank you for your feedback and collaboration!
I am reopening this issue. It seems important part/cases were missed and we should consider it again