質問 > その他 > Customize\Entityにてテーブルへ2個のフィールドを追加したのですが1個のデータしかとってこれない |
その他
スレッド表示 | 新しいものから | 前のトピック | 次のトピック | 下へ |
投稿者 | スレッド |
---|---|
umeda |
投稿日時: 2020/9/25 18:10
対応状況: −−−
|
新米 登録日: 2020/9/25 居住地: 投稿: 1 |
Customize\Entityにてテーブルへ2個のフィールドを追加したのですが1個のデータしかとってこれない ▼テンプレート
[EC-CUBE] 4.0.4 [レンタルサーバ] XAMPP [OS] windows10 [PHP] 7.4 [データベース] MarinaDB [WEBサーバ] Apache/2.4.46 (Win64) [ブラウザ] Chrome [導入プラグインの有無] なし [カスタマイズの有無]商品情報項目の追加 [現象] Customize\Entityにてdtb_product_imageテーブルへ2個のフィールドを追加したのですが1個のデータしかとってこれないので困っております。 どなたかご教諭頂ければと思っております。 下記サイトの真似をして、1個の項目は追加できたのですが https://qiita.com/ma33588/items/1768e997854884e670e0 次に商品画像の数を増やしたいと思い、dtb_product_imageへ2つのフィールドを追加したのですが、上側に定義した「main_list_image_new」の1つしかデータを取ってこれなく 試しに2つ目の定義した「main_image_new」を上側に定義しなおすと「main_image_new」だけデータが取得できます カスタムのTraitで追加できるのは1個しかできないのでしょうか? 下記はCustmize\Entity\ProductImageTrait.phpの内容です <?php //dtb_product_image 追加 カスタムフィールド namespace Customize\Entity; use Doctrine\ORM\Mapping as ORM; use Eccube\Annotation\EntityExtension; /** * @EntityExtension("Eccube\Entity\ProductImage") */ trait ProductImageTrait { // eccube4 dtb_product_imageへの追加画像 /** * @ORM\Column(type="string", nullable=true) */ public $main_image_new; public $main_list_image_new; /** * Set main_image_new. * * @param string $main_image_new * * @return Product */ public function setMainImageNew($main_image_new) { $this->main_image_new = $main_image_new; return $this; } /** * Get main_image_new. * * @return string */ public function getMainImageNew() { return $this->main_image_new; } /******************************************************/ /** * Set main_list_image_new. * * @param string $main_list_image_new * * @return Product */ public function setMainListImageNew($main_list_image_new) { $this->main_list_image_new = $main_list_image_new; return $this; } /** * Get $main_list_image_new * * @return string */ public function getMainListImageNew() { return $this->main_list_image_new; } } 下記はコントローラの内容です public function index($id) { //$product = $this->entityManager->getRepository('Eccube\Entity\Product')->find($id); $product = $this->productRepository->find($id); $ProductImage = $this->ProductImageRepository->find($id); //追加 return [ 'shop_name' => $this->baseInfo->getShopName(), 'maker_name' => $product->getMakerName(), 'product_name' => $product->getName(), 'main_list_image_new' => $ProductImage->getMainListImageNew(), //追加 'main_image_new' => $ProductImage->getMainImageNew() //追加 ]; } よろしくお願いいたします。 |
umebius |
投稿日時: 2020/9/25 22:18
対応状況: −−−
|
神 登録日: 2016/7/22 居住地: 投稿: 2085 |
Re: Customize\Entityにてテーブルへ2個のフィールドを追加したのですが1個のデータしかとってこれない
は、
ではないでしょうか?
|
スレッド表示 | 新しいものから | 前のトピック | 次のトピック | トップ |