>「キャッシュバグ修正済み」はtwigのバージョンアップ(差替え)ですか?
「キャッシュバグ修正済み」はtwigのバージョンアップを差替えたものです。
>CsvImportController.phpはカスタマイズされてますか?
いえ、一切いじっておりません。
↓
https://itoben.com/blog/2384.htmlこちらのEC-CUBE3.のカスタマイズ版をインストールした状態のままです。
>「ec-cube-3.0.15.zip」が、既に、手元にない場合は
>
https://github.com/EC-CUBE/ec-cube/tree/3.0.15>の「右端」「Clone or download」内「Download ZIP」で、ダウンロードしてください。
https://itoben.com/blog/2384.htmlのカスタマイズ版のインストール前の
「CsvImportController.php」の中身は下記のとおりです。
442行目の * カテゴリ登録CSVアップロードから564行目まで↓
* カテゴリ登録CSVアップロード
*/
public function csvCategory(Application $app, Request $request)
{
$form = $app['form.factory']->createBuilder('admin_csv_import')->getForm();
$headers = $this->getCategoryCsvHeader();
if ('POST' === $request->getMethod()) {
$form->handleRequest($request);
if ($form->isValid()) {
$formFile = $form['import_file']->getData();
if (!empty($formFile)) {
log_info('カテゴリCSV登録開始');
$data = $this->getImportData($app, $formFile);
if ($data === false) {
$this->addErrors('CSVのフォーマットが一致しません。');
return $this->render($app, $form, $headers, $this->categoryTwig);
}
$keys = array_keys($headers);
$columnHeaders = $data->getColumnHeaders();
if ($keys !== $columnHeaders) {
$this->addErrors('CSVのフォーマットが一致しません。');
return $this->render($app, $form, $headers, $this->categoryTwig);
}
$size = count($data);
if ($size < 1) {
$this->addErrors('CSVデータが存在しません。');
return $this->render($app, $form, $headers, $this->categoryTwig);
}
$headerSize = count($keys);
$this->em = $app['orm.em'];
$this->em->getConfiguration()->setSQLLogger(null);
$this->em->getConnection()->beginTransaction();
// CSVファイルの登録処理
foreach ($data as $row) {
if ($headerSize != count($row)) {
$this->addErrors(($data->key() + 1) . '行目のCSVフォーマットが一致しません。');
return $this->render($app, $form, $headers, $this->categoryTwig);
}
if ($row['カテゴリID'] == '') {
$Category = new Category();
} else {
if (!preg_match('/^\d+$/', $row['カテゴリID'])) {
$this->addErrors(($data->key() + 1) . '行目のカテゴリIDが存在しません。');
return $this->render($app, $form, $headers, $this->categoryTwig);
}
$Category = $app['eccube.repository.category']->find($row['カテゴリID']);
if (!$Category) {
$this->addErrors(($data->key() + 1) . '行目のカテゴリIDが存在しません。');
return $this->render($app, $form, $headers, $this->categoryTwig);
}
if ($row['カテゴリID'] == $row['親カテゴリID']) {
$this->addErrors(($data->key() + 1) . '行目のカテゴリIDと親カテゴリIDが同じです。');
return $this->render($app, $form, $headers, $this->categoryTwig);
}
}
if (Str::isBlank($row['カテゴリ名'])) {
$this->addErrors(($data->key() + 1) . '行目のカテゴリ名が設定されていません。');
return $this->render($app, $form, $headers, $this->categoryTwig);
} else {
$Category->setName(Str::trimAll($row['カテゴリ名']));
}
if ($row['親カテゴリID'] != '') {
if (!preg_match('/^\d+$/', $row['親カテゴリID'])) {
$this->addErrors(($data->key() + 1) . '行目の親カテゴリIDが存在しません。');
return $this->render($app, $form, $headers, $this->categoryTwig);
}
$ParentCategory = $app['eccube.repository.category']->find($row['親カテゴリID']);
if (!$ParentCategory) {
$this->addErrors(($data->key() + 1) . '行目の親カテゴリIDが存在しません。');
return $this->render($app, $form, $headers, $this->categoryTwig);
}
} else {
$ParentCategory = null;
}
if (Str::isNotBlank($row['カテゴリー説明'])) {
$Category->setCategoryDescription(Str::trimAll($row['カテゴリー説明']));
} else {
$Category->setCategoryDescription(null);
}
$Category->setParent($ParentCategory);
if ($ParentCategory) {
$Category->setLevel($ParentCategory->getLevel() + 1);
} else {
$Category->setLevel(1);
}
if ($app['config']['category_nest_level'] < $Category->getLevel()) {
$this->addErrors(($data->key() + 1) . '行目のカテゴリが最大レベルを超えているため設定できません。');
return $this->render($app, $form, $headers, $this->categoryTwig);
}
$status = $app['eccube.repository.category']->save($Category);
if (!$status) {
$this->addErrors(($data->key() + 1) . '行目のカテゴリが設定できません。');
}
if ($this->hasErrors()) {
return $this->render($app, $form, $headers, $this->categoryTwig);
}
$this->em->persist($Category);
}
$this->em->flush();
$this->em->getConnection()->commit();
log_info('カテゴリCSV登録完了');
$app->addSuccess('admin.category.csv_import.save.complete', 'admin');
}
}
}
return $this->render($app, $form, $headers, $this->categoryTwig);
}
>$this->addErrors('CSVのフォーマットが一致しません。getImportData');
>$this->addErrors('CSVのフォーマットが一致しません。columnHeaders');
>での、動作確認は出来ませんか?
すみません、こちらはどのようにしたら宜しいでしょうか。