Skip to content

Commit 3862672

Browse files
committed
Fix infinite loop issue
1 parent 7dea827 commit 3862672

File tree

3 files changed

+38
-5
lines changed

3 files changed

+38
-5
lines changed

app/code/Meta/Catalog/Model/Product/Feed/ProductRetriever/Configurable.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,23 @@ public function retrieve($offset = 1, $limit = self::LIMIT): array
140140
$configurableCollection->getSelect()->limit($limit, $offset);
141141

142142
if ($this->systemConfig->isAdditionalAttributesSyncDisabled()) {
143-
$products = $configurableCollection->getItems();
143+
$products = $configurableCollection->getData();
144144
} else {
145+
$productData = $configurableCollection->getData();
146+
$entityIds = [];
147+
foreach ($productData as $item) {
148+
if (isset($item['entity_id']) && ($item['entity_id'] != null || $item['entity_id'] != '')) {
149+
$entityIds[] = $item['entity_id'];
150+
}
151+
}
152+
if (empty($entityIds)) {
153+
return [];
154+
}
155+
145156
// in case of unsupported product we need complete data for products which is return by product repo api.
146157
$search = $this
147158
->searchCriteriaBuilder
148-
->addFilter('entity_id', array_keys($configurableCollection->getItems()), 'in')
159+
->addFilter('entity_id', $entityIds, 'in')
149160
->addFilter('store_id', $storeId)
150161
->create();
151162

app/code/Meta/Catalog/Model/Product/Feed/ProductRetriever/Other.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,20 @@ public function retrieve($offset = 1, $limit = self::LIMIT): array
152152
->order(new \Zend_Db_Expr('e.updated_at desc'))
153153
->limit($limit, $offset);
154154

155+
$productData = $collection->getData();
156+
$entityIds = [];
157+
foreach ($productData as $item) {
158+
if (isset($item['entity_id']) && ($item['entity_id'] != null || $item['entity_id'] != '')) {
159+
$entityIds[] = $item['entity_id'];
160+
}
161+
}
162+
if (empty($entityIds)) {
163+
return [];
164+
}
165+
155166
$search = $this
156167
->searchCriteriaBuilder
157-
->addFilter('entity_id', array_keys($collection->getItems()), 'in')
168+
->addFilter('entity_id', $entityIds, 'in')
158169
->addFilter('store_id', $storeId)
159170
->create();
160171

app/code/Meta/Catalog/Model/Product/Feed/ProductRetriever/Simple.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,23 @@ public function retrieve($offset = 1, $limit = null): array
139139
->limit($limit, $offset);
140140

141141
if ($this->systemConfig->isAdditionalAttributesSyncDisabled()) {
142-
$products = $collection->getItems();
142+
$products = $collection->getData();
143143
} else {
144+
$productData = $collection->getData();
145+
$entityIds = [];
146+
foreach ($productData as $item) {
147+
if (isset($item['entity_id']) && ($item['entity_id'] != null || $item['entity_id'] != '')) {
148+
$entityIds[] = $item['entity_id'];
149+
}
150+
}
151+
if (empty($entityIds)) {
152+
return [];
153+
}
154+
144155
// in case of unsupported product we need complete data for products which is return by product repo api.
145156
$search = $this
146157
->searchCriteriaBuilder
147-
->addFilter('entity_id', array_keys($collection->getItems()), 'in')
158+
->addFilter('entity_id', $entityIds, 'in')
148159
->addFilter('store_id', $storeId)
149160
->create();
150161

0 commit comments

Comments
 (0)