File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed
app/code/Magento/CatalogCustomerGraphQl/Model/Resolver/Product/Price Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -127,6 +127,11 @@ public function getProductRegularPrice($productId): ?float
127
127
*/
128
128
public function isLoaded (): bool
129
129
{
130
+ $ numFilterProductIds = count (array_unique ($ this ->filterProductIds ));
131
+ if ($ numFilterProductIds > count ($ this ->products )) {
132
+ //New products were added to the filter after load, so we should reload
133
+ return false ;
134
+ }
130
135
return $ this ->loaded ;
131
136
}
132
137
@@ -146,10 +151,26 @@ private function load(): void
146
151
$ productCollection ->load ();
147
152
$ productCollection ->addTierPriceDataByGroupId ($ this ->customerGroupId );
148
153
154
+ $ this ->setProducts ($ productCollection );
155
+ $ this ->loaded = true ;
156
+ }
157
+
158
+ /**
159
+ * Set products from collection
160
+ *
161
+ * @param Collection $productCollection
162
+ */
163
+ private function setProducts (Collection $ productCollection ): void
164
+ {
165
+ $ this ->products = [];
166
+
149
167
foreach ($ productCollection as $ product ) {
150
168
$ this ->products [$ product ->getId ()] = $ product ;
151
169
}
152
170
153
- $ this ->loaded = true ;
171
+ $ missingProducts = array_diff ($ this ->filterProductIds , array_keys ($ this ->products ));
172
+ foreach (array_unique ($ missingProducts ) as $ missingProductId ) {
173
+ $ this ->products [$ missingProductId ] = null ;
174
+ }
154
175
}
155
176
}
You can’t perform that action at this time.
0 commit comments