@
iyaozhen 代码这里:
代码:
$total = count($importData);
$page = intval(ceil($total / $pageNumber));
for ($p = 0; $p < $page; $p++)
{
$start = $p * $pageNumber;
$sliceData = array_slice($importData, $start, $pageNumber, true);
$productSQLValue = false;
foreach ($sliceData as $fieldValue)
{
dump($fieldValue);
// if (!$fieldValue['modelName'] || !$fieldValue['type'] || !$fieldValue['category'])
// continue;
// $categoryID = $this->getProductCategoryID($fieldValue['category']);
// $typeID = $this->getProductTypeID($fieldValue['type']);
// if (!$categoryID || !$typeID)
// continue;
// $model = $this->getModel($fieldValue['brandName'], $fieldValue['modelName']);
// $resourceModel = $model['resourceModel'];
// if ($resourceModel)
// {
// $resourceModel = $resourceModel->getId();
// }
// $product = $this->entityManager->getRepository('DemoProductBundle:Product')->findOneBy(array('creator' => $productCreator, 'model' => $model['productModel']));
// $row = array();
// if ($product)
// {
// $row['id'] = $product->getId();
// $row['sn'] = $product->getSn();
// $row['created'] = $product->getCreated()->format('Y-m-d H:i:s');
// } else {
// $row['id'] = $latestProductID + $pID;
// $row['sn'] = $this->redis->getNumber('product-sku');
// $row['created'] = date('Y-m-d H:i:s');
// $pID++;
// }
// $row['title'] = $fieldValue['title'];
// $row['excerpt'] = $fieldValue['excerpt'];
// $row['description'] = $fieldValue['description'];
// $row['city'] = $this->getProductCityID($fieldValue['originPlace']);
// $row['model'] = $model['productModel']->getId();
// $row['resource_model'] = $resourceModel;
// $row['category'] = $categoryID;
// $row['type'] = $typeID;
// $row['retail_price'] = $fieldValue['retailPrice'];
// $row['status'] = 1;
// $row['modified'] = date('Y-m-d H:i:s');
// dump($row);
// $productSQLValue .= "('". implode("','", $row) . "'),";
}
dump($p);
// dump($productSQLValue);
// dump($sliceData);
dump(date('H:i:s'));
// if ($p > 3)
// break;
}
输出 dump($fieldValue);可以工作
// dump($productSQLValue);如果想输出组合后的 sql,就挂掉了。