I have a problem with inserting into the database. It should be at the same time to insert about 5000 records. I use ecommerce module. How to accelerate the insertion, as DataObjects takes a very long time ... For ongoing connection to the SOAP server, and information acquisition and storage of the ecommerce module. Received errors on the memory utilization, but hold it up to 128MB to avoid errors, execution time increases over the 300S.
Maybe you have a recipe?
code sample:
function GetProductList($Name, $ID, $Parent){
$results = $this->cacheToFile('getResultsProductList', 3600, false, array($Name, $ID));
if (isset($results))
foreach ($results->GetProductListResult->ProductList->Product as $key => $item){
$isNew = DataObject::get_one('AccProduct', '`SupplierCode` = "'. Convert::raw2sql($item->SupplierCode) .'"');
if ($isNew){
unset($this->GetProductList->GetProductListResult->ProductList->Product[$key]);
continue;
}
//$Parent = DataObject::get_one('AccProductGroup', "`ClassId` = '$item->ClassId'");
//
if (!$Parent){
unset($this->GetProductList->GetProductListResult->ProductList->Product[$key]);
continue;
}
$product = new AccProduct();
//
$product->MenuTitle = $item->Name;
$product->Title = $item->Name;
$product->URLSegment = strtolower(trim(str_replace(' ', '-', $item->Name)));
$product->MetaTitle = $Parent->Title . " - " . $item->Name;
$product->MetaDescription = $item->Name;
$product->MetaKeywords = trim(str_replace(' ', ',', $item->Name));
$product->ProvideComments = 0;
$product->Sort = $this->Sort++;
$product->ParentID = $Parent->ID;
$product->Content = '';
$product->Price = $item->Price;
$product->Warranty = $item->Warranty;
$product->Quantity = $item->Quantity;
$product->FeaturedProduct = 0;
$product->AllowPurchase = 1;
$product->Weight = $item->GrossWeight;
$product->DateExpected = $item->DateExpected;
$product->RecommendedRetailPrice = $item->RecommendedRetailPrice;
$product->IsNewProduct = $item->IsNewProduct;
$product->SupplierCode = $item->SupplierCode;
$product->PartNumber = $item->PartNumber;
$product->Segment = $item->SegmentId;
$product->Group = $item->GroupId;
$product->Class = $item->ClassId;
$product->Series = $item->SeriesId;
// print "<pre>";
// //var_dump($this->getProductClassification($item->ClassId));
// //Debug::show($this->getProductClassification($item->ClassId));
// print "</pre>";
if (!$isNew){
$product->writeToStage('Stage');
$product->publish('Stage', 'Live');
}else {
$isNew->destroy();
}
unset($this->GetProductList->GetProductListResult->ProductList->Product[$key]);
$product->destroy();
$Parent->destroy();
}
//Sunaikinam gauta sarasa produktu
unset($results);
return true;
}