Skip to content

Changed Validation to get store for block #11601

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions app/code/Magento/Cms/Model/ResourceModel/Block.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

use Magento\Cms\Api\Data\BlockInterface;
use Magento\Framework\DB\Select;
use Magento\Framework\EntityManager\EntityManager;
use Magento\Framework\EntityManager\MetadataPool;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Model\AbstractModel;
use Magento\Framework\EntityManager\MetadataPool;
use Magento\Framework\EntityManager\EntityManager;
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
use Magento\Framework\Model\ResourceModel\Db\Context;
use Magento\Store\Model\Store;
Expand Down Expand Up @@ -183,7 +183,7 @@ public function getIsUniqueBlockToStores(AbstractModel $object)
$entityMetadata = $this->metadataPool->getMetadata(BlockInterface::class);
$linkField = $entityMetadata->getLinkField();

if ($this->_storeManager->hasSingleStore()) {
if ($this->_storeManager->isSingleStoreMode()) {
$stores = [Store::DEFAULT_STORE_ID];
} else {
$stores = (array)$object->getData('stores');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The store validation seems to be broken here as the data set on the object is under store_id and not stores.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or maybe better still would be to use the getStores method that is against the Block model.

Expand Down Expand Up @@ -230,7 +230,7 @@ public function lookupStoreIds($id)
'cbs.' . $linkField . ' = cb.' . $linkField,
[]
)
->where('cb.' . $entityMetadata->getIdentifierField() . ' = :block_id');
->where('cb.' . $entityMetadata->getIdentifierField() . ' = :block_id');

return $connection->fetchCol($select, ['block_id' => (int)$id]);
}
Expand Down