バージョン選択

フォーラム

メニュー

オンライン状況

101 人のユーザが現在オンラインです。 (92 人のユーザが フォーラム を参照しています。)
登録ユーザ: 0
ゲスト: 101
もっと...

サイト内検索

質問 > 管理機能 > 商品、会員の追加項目を受注にも反映させる

管理機能

新規スレッドを追加する

フラット表示 前のトピック | 次のトピック
投稿者 スレッド
kumaan
投稿日時: 2023/9/14 16:49
対応状況: 解決済
新米
登録日: 2023/9/11
居住地:
投稿: 9
商品、会員の追加項目を受注にも反映させる
お世話になっております。
見様見真似でEC-CUBEをカスタムして、BtoBサイトを構築中なのですがどうにも行き詰まってしまったので教えてください。

商品登録と会員登録の項目に、独自の項目を追加しました。
それらの情報を、受注時にも引き継ぎたいのです。

受注登録画面に項目を表示するために、

dtb_oder

に追加項目のテーブルを作成した後、

OderTypeExtension.php

を作成しました。


namespace Customize\Form\Extension\Admin;
use Eccube\Form\Type\Admin\OrderType;
use Symfony\Component\Form\AbstractTypeExtension;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\Extension\Core\Type\TextType;



class OrderTypeExtension extends AbstractTypeExtension
{

    public static function getExtendedTypes(): iterable
    {
        yield OrderType::class;
    }
    

    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            //請求先コード
            ->add('demandcode',TextType::class,[
                'required' => true
            ])
            //得意先コード
            ->add('customercode',TextType::class,[
                'required' => true
            ])
            //得意先名1
            ->add('customername1',TextType::class,[
                'required' => true
            ])
            //得意先名2
            ->add('customername2',TextType::class,[
                'required' => false
            ])
            //得意先FAX番号
            ->add('customerfaxno',TextType::class,[
                'required' => false
            ])
            //担当者コード
            ->add('chargecode',TextType::class,[
                'required' => true
            ])
            //倉庫コード
            ->add('warehousecode',TextType::class,[
                'required' => true
            ])
            //代引きなしフラグ
            ->add('codnotflgch',TextType::class,[
                'required' => true,
                'data' => '0',
            ]) ;


    }

}



その後で、Resource>template>Oderよりedit.twigをCustomize>template>admin>Oderにコピーして、該当箇所に下記のようにフォームを追記しました。

<div class="row mb-2">
         <div class="col-3">
           <span>{{ 'admin.common.customercode'|trans }}</span>
           <span class="badge bg-primary ms-1">{{ 'admin.common.required'|trans }}</span>
          </div>
                 <div class="col">
                    <div class="row">
                       <div class="col">
                           {{ form_widget(form.customercode) }}
                          </div>
                     </div>
                  <div class="row">
                     <div class="col">
                    {{ form_errors(form.customercode) }}
                       </div>
                       </div>
                  </div>
             </div>


ですが、管理画面側でシステムエラーが発生してうまくいきません。
エラーログは下記のとおりです。


[2023-09-14T16:47:21.465313+09:00] admin.ERROR [c64241ec] [0fccf3b] [1] [Eccube\Log\Logger:log:64] - システムエラーが発生しました。 ["Can't get a way to read the property \"demandcode\" in class \"Eccube\\Entity\\Order\".","/home/redheart/ドメイン/public_html/ec-cube/vendor/symfony/property-access/PropertyAccessor.php",511,"#0 /home/redheart/ドメイン/public_html/ec-cube/vendor/symfony/property-access/PropertyAccessor.php(154): Symfony\\Component\\PropertyAccess\\PropertyAccessor->readProperty(Array, 'demandcode', false)\n#1 /home/redheart/ドメイン/public_html/ec-cube/vendor/symfony/form/Extension/Core/DataAccessor/PropertyPathAccessor.php(92): Symfony\\Component\\PropertyAccess\\PropertyAccessor->getValue(Object(Eccube\\Entity\\Order), Object(Symfony\\Component\\PropertyAccess\\PropertyPath))\n#2 /home/redheart/ドメイン/public_html/ec-cube/vendor/symfony/form/Extension/Core/DataAccessor/PropertyPathAccessor.php(48): Symfony\\Component\\Form\\Extension\\Core\\DataAccessor\\PropertyPathAccessor->getPropertyValue(Object(Eccube\\Entity\\Order), Object(Symfony\\Component\\PropertyAccess\\PropertyPath))\n#3 /home/redheart/ドメイン/public_html/ec-cube/vendor/symfony/form/Extension/Core/DataAccessor/ChainAccessor.php(40): Symfony\\Component\\Form\\Extension\\Core\\DataAccessor\\PropertyPathAccessor->getValue(Object(Eccube\\Entity\\Order), Object(Symfony\\Component\\Form\\Form))\n#4 /home/redheart/ドメイン/public_html/ec-cube/vendor/symfony/form/Extension/Core/DataMapper/DataMapper.php(57): Symfony\\Component\\Form\\Extension\\Core\\DataAccessor\\ChainAccessor->getValue(Object(Eccube\\Entity\\Order), Object(Symfony\\Component\\Form\\Form))\n#5 /home/redheart/ドメイン/public_html/ec-cube/vendor/symfony/form/Form.php(388): Symfony\\Component\\Form\\Extension\\Core\\DataMapper\\DataMapper->mapDataToForms(Object(Eccube\\Entity\\Order), Object(RecursiveIteratorIterator))\n#6 /home/redheart/ドメイン/public_html/ec-cube/vendor/symfony/form/Form.php(492): Symfony\\Component\\Form\\Form->setData(Object(Eccube\\Entity\\Order))\n#7 /home/redheart/ドメイン/public_html/ec-cube/vendor/symfony/form/FormBuilder.php(210): Symfony\\Component\\Form\\Form->initialize()\n#8 /home/redheart/ドメイン/public_html/ec-cube/src/Eccube/Controller/Admin/Order/EditController.php(220): Symfony\\Component\\Form\\FormBuilder->getForm()\n#9 /home/redheart/ドメイン/public_html/ec-cube/vendor/symfony/http-kernel/HttpKernel.php(163): Eccube\\Controller\\Admin\\Order\\EditController->index(Object(Symfony\\Component\\HttpFoundation\\Request), Object(Symfony\\Bundle\\FrameworkBundle\\Routing\\Router), NULL)\n#10 /home/redheart/ドメイン/public_html/ec-cube/vendor/symfony/http-kernel/HttpKernel.php(75): Symfony\\Component\\HttpKernel\\HttpKernel->handleRaw(Object(Symfony\\Component\\HttpFoundation\\Request), 1)\n#11 /home/redheart/ドメイン/public_html/ec-cube/vendor/symfony/http-kernel/Kernel.php(202): Symfony\\Component\\HttpKernel\\HttpKernel->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n#12 /home/redheart/ドメイン/public_html/ec-cube/index.php(83): Symfony\\Component\\HttpKernel\\Kernel->handle(Object(Symfony\\Component\\HttpFoundation\\Request))\n#13 {main}"] [GET, /ec-cube/administrator/order/new, 61.194.59.26, https://ドメイン/ec-cube/administrator/order, Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36]


そもそものお作法が間違っているのか、作法はあっているけどコードの表記がまずいのか、ご教授ください。
よろしくお願いいたします。
フラット表示 前のトピック | 次のトピック


題名 投稿者 日時
 » 商品、会員の追加項目を受注にも反映させる kumaan 2023/9/14 16:49
     Re: 商品、会員の追加項目を受注にも反映させる h_tanaka 2023/9/14 16:56
       Re: 商品、会員の追加項目を受注にも反映させる kumaan 2023/9/15 11:38
         Re: 商品、会員の追加項目を受注にも反映させる h_tanaka 2023/9/15 11:43
         Re: 商品、会員の追加項目を受注にも反映させる h_tanaka 2023/9/15 11:49
           Re: 商品、会員の追加項目を受注にも反映させる kumaan 2023/9/15 14:41
             Re: 商品、会員の追加項目を受注にも反映させる h_tanaka 2023/9/15 14:57
               Re: 商品、会員の追加項目を受注にも反映させる kumaan 2023/9/15 15:56

 



ログイン


EC-CUBE公式 Amazon Payプラグイン

統計情報

総メンバー数は97,426名です
総投稿数は111,840件です

投稿数ランキング

1
seasoft
7369
2
468
3217
3
AMUAMU
2712
4
nanasess
2325
5
umebius
2085
6
yuh
1894
7
h_tanaka
1873
8
red
1574
9
mcontact
1555
10
tsuji
958
11
fukap
907
12
shutta
835
13
tao_s
805
14 ramrun 789
15 karin 689
16 sumida 641
17
homan
633
18 DELIGHT 572
19
patapata
502
20
balisys
502


ネットショップの壺

EC-CUBEインテグレートパートナー

Copyright© EC-CUBE CO.,LTD. All Rights Reserved.