|
11 | 11 | */
|
12 | 12 | namespace Magento\Reports\Model\ResourceModel;
|
13 | 13 |
|
| 14 | +use Magento\Framework\App\ResourceConnection; |
| 15 | +use Magento\Store\Model\StoreManagerInterface; |
| 16 | + |
14 | 17 | class Helper extends \Magento\Framework\DB\Helper implements \Magento\Reports\Model\ResourceModel\HelperInterface
|
15 | 18 | {
|
16 | 19 | /**
|
17 |
| - * @param \Magento\Framework\App\ResourceConnection $resource |
| 20 | + * @var StoreManagerInterface |
| 21 | + */ |
| 22 | + protected StoreManagerInterface $storeManager; |
| 23 | + |
| 24 | + /** |
| 25 | + * @param ResourceConnection $resource |
| 26 | + * @param StoreManagerInterface $storeManager |
18 | 27 | * @param string $modulePrefix
|
19 | 28 | */
|
20 |
| - public function __construct(\Magento\Framework\App\ResourceConnection $resource, $modulePrefix = 'reports') |
21 |
| - { |
| 29 | + public function __construct( |
| 30 | + ResourceConnection $resource, |
| 31 | + StoreManagerInterface $storeManager, |
| 32 | + string $modulePrefix = 'reports' |
| 33 | + ) { |
| 34 | + $this->storeManager = $storeManager; |
22 | 35 | parent::__construct($resource, $modulePrefix);
|
23 | 36 | }
|
24 | 37 |
|
@@ -94,11 +107,15 @@ public function updateReportRatingPos($connection, $type, $column, $mainTable, $
|
94 | 107 | $cols['period'] = $periodCol;
|
95 | 108 | $cols[$column] = 't.' . $column;
|
96 | 109 | $cols['rating_pos'] = 't.rating_pos';
|
97 |
| - $ratingSelect->from($ratingSubSelect, $cols); |
98 | 110 |
|
99 |
| - $sql = $ratingSelect->insertFromSelect($aggregationTable, array_keys($cols)); |
100 |
| - $connection->query("SET @pos = 0, @prevStoreId = -1, @prevPeriod = '0000-00-00'"); |
101 |
| - $connection->query($sql); |
| 111 | + foreach ($this->storeManager->getStores(true) as $store) { |
| 112 | + $ratingSubSelect->where('t.store_id = ' . $store->getId()); |
| 113 | + $ratingSelect->from($ratingSubSelect, $cols); |
| 114 | + $sql = $ratingSelect->insertFromSelect($aggregationTable, array_keys($cols)); |
| 115 | + $connection->query("SET @pos = 0, @prevStoreId = -1, @prevPeriod = '0000-00-00'"); |
| 116 | + $connection->query($sql); |
| 117 | + } |
| 118 | + |
102 | 119 | return $this;
|
103 | 120 | }
|
104 | 121 | }
|
0 commit comments