|
9 | 9 | /**
|
10 | 10 | * Abstract Rule entity resource collection model
|
11 | 11 | *
|
| 12 | + * phpcs:disable Magento2.Classes.AbstractApi |
12 | 13 | * @api
|
13 | 14 | * @since 100.0.2
|
14 | 15 | */
|
@@ -83,11 +84,21 @@ public function addWebsiteFilter($websiteId)
|
83 | 84 | if ($website instanceof \Magento\Store\Model\Website) {
|
84 | 85 | $websiteIds[$index] = $website->getId();
|
85 | 86 | }
|
| 87 | + $websiteIds[$index] = (int) $websiteIds[$index]; |
86 | 88 | }
|
| 89 | + |
| 90 | + $websiteSelect = $this->getConnection()->select(); |
| 91 | + $websiteSelect->from( |
| 92 | + $this->getTable($entityInfo['associations_table']), |
| 93 | + [$entityInfo['rule_id_field']] |
| 94 | + )->distinct( |
| 95 | + true |
| 96 | + )->where( |
| 97 | + $this->getConnection()->quoteInto($entityInfo['entity_id_field'] . ' IN (?)', $websiteIds) |
| 98 | + ); |
87 | 99 | $this->getSelect()->join(
|
88 |
| - ['website' => $this->getTable($entityInfo['associations_table'])], |
89 |
| - $this->getConnection()->quoteInto('website.' . $entityInfo['entity_id_field'] . ' IN (?)', $websiteIds) |
90 |
| - . ' AND main_table.' . $entityInfo['rule_id_field'] . ' = website.' . $entityInfo['rule_id_field'], |
| 100 | + ['website' => $websiteSelect], |
| 101 | + 'main_table.' . $entityInfo['rule_id_field'] . ' = website.' . $entityInfo['rule_id_field'], |
91 | 102 | []
|
92 | 103 | );
|
93 | 104 | }
|
@@ -127,11 +138,11 @@ public function addIsActiveFilter($isActive = 1)
|
127 | 138 | }
|
128 | 139 |
|
129 | 140 | /**
|
130 |
| - * Retrieve correspondent entity information (associations table name, columns names) |
131 |
| - * of rule's associated entity by specified entity type |
| 141 | + * Retrieve correspondent entity information of rule's associated entity by specified entity type |
132 | 142 | *
|
133 |
| - * @param string $entityType |
| 143 | + * (associations table name, columns names) |
134 | 144 | *
|
| 145 | + * @param string $entityType |
135 | 146 | * @throws \Magento\Framework\Exception\LocalizedException
|
136 | 147 | * @return array
|
137 | 148 | */
|
|
0 commit comments