質問 > その他 > テーブルに列を追加 |
その他
スレッド表示 | 新しいものから | 前のトピック | 次のトピック | 下へ |
投稿者 | スレッド |
---|---|
akadota |
投稿日時: 2020/10/3 17:38
対応状況: 開発中
|
半人前 登録日: 2020/8/11 居住地: 投稿: 24 |
テーブルに列を追加 本当は購入画面で項目を追加したいのですが、試しに下記の項目追加を試しています。
が、エラーが出てよくわかりません。よく他の方がサンプルにされてますが、どうやってエラーを無くしているのでしょうか? 【テーブルに列を追加してControllerからアクセス】 https://qiita.com/ma33588/items/1768e997854884e670e0 1)app/Customize/Entity/ProductTrait.php 追加 2)Proxyクラスの生成 3)app/proxy/entity/Product.php が作成され 4)DBアップデート(phpMyadminで見ると列は追加されていました) 5)app/Customize/Controller/SamplePageController.php 作成 この後EC-CUBE画面でエラー。管理画面にも入れないです。 【エラー内容】 (1/2) InvalidArgumentException Expected to find class "Customize\Controller\SamplePageController" in file "/***/public_html/ec-test/app/Customize/Controller/SamplePageController.php" while importing services from resource "../../../app/Customize/*", but it was not found! Check the namespace prefix used with the resource. (2/2) FileLoaderLoadException Expected to find class "Customize\Controller\SamplePageController" in file "/***/public_html/ec-test/app/Customize/Controller/SamplePageController.php" while importing services from resource "../../../app/Customize/*", but it was not found! Check the namespace prefix used with the resource in /***/public_html/ec-test/app/config/eccube/services.yaml (which is loaded in resource "/***/public_html/ec-test/app/config/eccube/services.yaml"). 何が間違っているのでしょうか? |
468 |
投稿日時: 2020/10/4 7:50
対応状況: −−−
|
神 登録日: 2008/10/26 居住地: 投稿: 3217 |
Re: テーブルに列を追加 SamplePageController.phpのnamespaceの記述が間違っているのかもしれません。
パスが正しいか確認してみてください。
|
akadota |
投稿日時: 2020/10/5 10:39
対応状況: −−−
|
半人前 登録日: 2020/8/11 居住地: 投稿: 24 |
Re: テーブルに列を追加 確かに『SamplePageController.php』をサーバーから削除するとEC-CUBEが動きます。namespaceは『namespace Customize\Controller;』となっていますがどこが間違っているのかがわかりません><;
【SamplePageController.phの記述】 namespace Customize\Controller; use Eccube\Controller\AbstractController; use Eccube\Entity\BaseInfo; use Eccube\Entity\Product; use Eccube\Repository\BaseInfoRepository; use Eccube\Repository\ProductRepository; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\Routing\Annotation\Route; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; class SamplePageController extends AbstractController { /** @var BaseInfo */ protected $baseInfo; /** @var Product */ protected $productRepository; /** * SamplePageController constructor. * @param BaseInfoRepository $baseInfoRepository * @param ProductRepository $productRepository */ public function __construct( BaseInfoRepository $baseInfoRepository, ProductRepository $productRepository ) { $this->baseInfo = $baseInfoRepository->get(); $this->productRepository = $productRepository; } /** * @Route("/sample/{id}", name="sample_index") * @Template("Sample/index.twig") */ public function index($id) { // $product = $this->entityManager->getRepository('Eccube\Entity\Product')->find($id); $product = $this->productRepository->find($id); return [ 'shop_name' => $this->baseInfo->getShopName(), 'maker_name' => $product->getMakerName(), 'product_name' => $product->getName(), ]; } } |
スレッド表示 | 新しいものから | 前のトピック | 次のトピック | トップ |