Closed arnoudhgz closed 4 years ago
Out of curiosity before releasing the new version with your PR included. How does this scenario happen?
if ($collection->count() === 0) {
return [];
}
$entityIds = $collection->getAllIds();
if (count($entityIds) === 0) { // <---- included in your pull
return [];
}
Apparently $collection->count() is nonzero but $collection->getAllIds() is empty?
@edwinljacobs the getAllIds()
method on the collection is also actually yours ;)
Under the hood it triggers this method (also yours) :
public function getExported(): array
{
$result = [];
foreach ($this as $entity) {
if (!$entity->shouldExport()) {
continue;
}
$result[$entity->getId()] = $entity;
}
return $result;
}
So if a batch of products are all skipped, you end up with an empty array.
Ah yes, should have clicked further in the method calls. I do see my name when annotating the code.... and hence should have known that unexported entities are still in the collection.
Case closed and released in https://github.com/EmicoEcommerce/Magento2TweakwiseExport/releases/tag/v1.5.6
With kind regards!
@edwinljacobs haha no worries, glad I could help.
Magento: 2.3.4 Extension version: 2.1.10
The method
getStockItemMap
does a filtering on all items from the collection. We got a case that the result of$collection->getAllIds()
was empty, which triggered a MySQL error when the filtering is done in Magento.MySQL error:
Source: https://github.com/EmicoEcommerce/Magento2TweakwiseExport/blob/ece19e55869afc9be3a9398b28c56fae3fcb936f/src/Model/Write/Products/CollectionDecorator/StockData/StockItemMapProvider.php#L61