Skip to content

Commit 9e88279

Browse files
committed
Update for readAllWebsites and readAllStores methods to check if db table exists before fetch data from table.
1 parent c252363 commit 9e88279

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

Diff for: app/code/Magento/Store/Model/ResourceModel/Store.php

+9-4
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,16 @@ protected function _changeGroup(\Magento\Framework\Model\AbstractModel $model)
166166
*/
167167
public function readAllStores()
168168
{
169-
$select = $this->getConnection()
170-
->select()
171-
->from($this->getTable('store'));
169+
$stores = [];
170+
if ($this->getConnection()->isTableExists($this->getMainTable())) {
171+
$select = $this->getConnection()
172+
->select()
173+
->from($this->getTable($this->getMainTable()));
172174

173-
return $this->getConnection()->fetchAll($select);
175+
$stores = $this->getConnection()->fetchAll($select);
176+
}
177+
178+
return $stores;
174179
}
175180

176181
/**

Diff for: app/code/Magento/Store/Model/ResourceModel/Website.php

+7-5
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,14 @@ protected function _initUniqueFields()
4747
public function readAllWebsites()
4848
{
4949
$websites = [];
50-
$select = $this->getConnection()
51-
->select()
52-
->from($this->getTable('store_website'));
50+
if ($this->getConnection()->isTableExists($this->getMainTable())) {
51+
$select = $this->getConnection()
52+
->select()
53+
->from($this->getTable($this->getMainTable()));
5354

54-
foreach ($this->getConnection()->fetchAll($select) as $websiteData) {
55-
$websites[$websiteData['code']] = $websiteData;
55+
foreach ($this->getConnection()->fetchAll($select) as $websiteData) {
56+
$websites[$websiteData['code']] = $websiteData;
57+
}
5658
}
5759

5860
return $websites;

0 commit comments

Comments
 (0)