Closed tfe2012 closed 6 years ago
on item-manager clear(), all persisted data is cleared. And your $supplier object is not managed anymore by item-manager.
One word around: you can clear only items as SupplierProduct by:
$itemManager->getRepository(SupplierProduct::class)->clear();
Thx, now I understand idea. If you can, it would be great to add this information to information.
$refreshCount = 0;
while (($data = fgetcsv($handle, 1000, ",")) !== false) { $refreshCount++; $supplierProduct = new SupplierProduct(); $this->supplierProductModel->save($supplierProduct); if ($refreshCount > 100) { // Point 1. $this->supplierProductModel->clear(); $refreshCount = 0; } }
// Point 2. $this->supplierModel->save($supplier);
If I try read file, and not cleaning (point 1) itemManager, I get memory leak, ItemManager use all ram.
If I cleaning, than on point 2 save doesn't work.
Save looks like: $version++; $object->setVersion($version); $this->itemManager->flush();
A question is how to iterate huge files?