Get ProductCategories
public getProductCategories ( ) : Doctrine\Common\Collections\Collection | ||
Результат | Doctrine\Common\Collections\Collection |
/** * {@inheritDoc} */ public function getProductCategories() { $this->__initializer__ && $this->__initializer__->__invoke($this, 'getProductCategories', array()); return parent::getProductCategories(); }
/** * 商品カテゴリの削除、登録 */ protected function createProductCategory($row, Product $Product, $app, $data) { // カテゴリの削除 $ProductCategories = $Product->getProductCategories(); foreach ($ProductCategories as $ProductCategory) { $Product->removeProductCategory($ProductCategory); $this->em->remove($ProductCategory); $this->em->flush($ProductCategory); } if ($row['商品カテゴリ(ID)'] == '') { // 入力されていなければ削除のみ return; } // カテゴリの登録 $categories = explode(',', $row['商品カテゴリ(ID)']); $rank = 1; foreach ($categories as $category) { if (preg_match('/^\\d+$/', $category)) { $Category = $app['eccube.repository.category']->find($category); if (!$Category) { $this->addErrors($data->key() + 1 . '行目の商品カテゴリ(ID)「' . $category . '」が存在しません。'); } else { $ProductCategory = new ProductCategory(); $ProductCategory->setProductId($Product->getId()); $ProductCategory->setCategoryId($Category->getId()); $ProductCategory->setProduct($Product); $ProductCategory->setCategory($Category); $ProductCategory->setRank($rank); $Product->addProductCategory($ProductCategory); $rank++; $this->em->persist($ProductCategory); } } else { $this->addErrors($data->key() + 1 . '行目の商品カテゴリ(ID)「' . $category . '」が存在しません。'); } } }
/** * @param Product $product * @param AdContents $ad_contents */ private function createAdGroupWithCategory(Product $product, AdContents $ad_contents) { $group_name = CsvContentsUtil::clipText($product->getName() . '×' . 'カテゴリ', 50); $group = new AdGroup($group_name, $ad_contents); $categories = $product->getProductCategories(); foreach ($categories as $category) { $category_name = $category->getCategory()->getName(); $group->addKeyword($product->getName() . ' ' . $category_name); } if (!empty($group->getKeywords())) { array_push($this->ad_groups, $group); } }