/**
* タグの登録
*
* @param array $row
* @param Product $Product
* @param Application $app
* @param CsvImportService $data
*/
protected function createProductTag($row, Product $Product, $app, $data)
{
// タグの削除
$ProductTags = $Product->getProductTag();
foreach ($ProductTags as $ProductTags) {
$Product->removeProductTag($ProductTags);
$this->em->remove($ProductTags);
}
if ($row['タグ(ID)'] == '') {
return;
}
// タグの登録
$tags = explode(',', $row['タグ(ID)']);
foreach ($tags as $tag_id) {
$Tag = null;
if (preg_match('/^\\d+$/', $tag_id)) {
$Tag = $app['eccube.repository.master.tag']->find($tag_id);
if ($Tag) {
$ProductTags = new ProductTag();
$ProductTags->setProduct($Product)->setTag($Tag);
$Product->addProductTag($ProductTags);
$this->em->persist($ProductTags);
}
}
if (!$Tag) {
$this->addErrors($data->key() + 1 . '行目のタグ(ID)「' . $tag_id . '」が存在しません。');
}
}
}