質問 > フロント機能 > Entity has to be managed or scheduled for removal for single computation というエラーについて |
フロント機能
スレッド表示 | 新しいものから | 前のトピック | 次のトピック | 下へ |
投稿者 | スレッド |
---|---|
HelloBetty |
投稿日時: 2021/4/30 8:05
対応状況: −−−
|
新米 登録日: 2021/2/10 居住地: 投稿: 10 |
Entity has to be managed or scheduled for removal for single computation というエラーについて EC-CUBE 4.0.5
PHP 7.2.31 先日の CartItemComparator の実装でエラーになってしまう https://xoops.ec-cube.net/modules/newbb/viewtopic.php?topic_id=25697&forum=10 の延長なのですが、 上記で作成した src/Eccube/Service/Cart/ProductClassAndOptionComparator.php の中で 独自にProductClassに追加したメーカーID(maker_id)を元にカートを別けようとしています functionに渡される $Item1、$Item2にmaker_idを乗せる様に下記のカスタマイズを致しました ●src/Eccube/Entity/CartItem.php /** * @var string * * @ORM\Column(name="maker_id", type="integer", options={"unsigned":true}) */ private $maker_id; /** * @param integer $maker_id * * @return CartItem */ public function setMakerid($maker_id) { $this->maker_id = $maker_id; return $this; } /** * @return string */ public function getMakerid() { return $this->maker_id; } ●src/Eccube/Form/Type/AddCartType.php : function buildForm $builder->add('maker_id', HiddenType::class, [ 'data' => $data['maker_id'] ] ); ●src/Eccube/Service/CartService.php $newItem->setMakerid($ProductClass->maker_id); ●src/Eccube/Controller/ProductController.php : function addCart $this->cartService->addProduct($addCartData['maker_id']); ●src/Eccube/Controller/ProductController.php : function addCart $this->cartService->addProduct($addCartData['maker_id'])->save(); この状態でsrc/Eccube/Service/Cart/ProductClassAndOptionComparator.php 内でdumpしたところ $Item1、$Item2 にmaker_idは含まれる様になったのですが 表題の「Entity has to be managed or scheduled for removal for single computation」というエラーが発生するようになりました このエラーの解消方法が解らずお教え頂きたく思います もしくは、カスタマイズの根本的なところで間違っているようでしたらご指摘頂ければと思います どうぞよろしくお願い致します 以下、エラー全文です(ディレクトリ名など一部省略) - システムエラーが発生しました。 [ "Entity has to be managed or scheduled for removal for single computation Eccube\\Entity\\CartItem@000000004778bba0000000007c75001e", "/xxx/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php",516," #0 /xxx/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php(344): Doctrine\\ORM\\UnitOfWork->computeSingleEntityChangeSet(Object(Eccube\\Entity\\CartItem))\n #1 /xxx/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php(368): Doctrine\\ORM\\UnitOfWork->commit(Object(Eccube\\Entity\\CartItem))\n #2 /xxx/var/cache/prod/ContainerXrbogn0/EntityManager_9a5be93.php(83): Doctrine\\ORM\\EntityManager->flush(Object(Eccube\\Entity\\CartItem))\n #3 /xxx/src/Eccube/Service/CartService.php(295): EntityManager_9a5be93->flush(Object(Eccube\\Entity\\CartItem))\n #4 /xxx/src/Eccube/Service/CartService.php(372): Eccube\\Service\\CartService->restoreCarts(Array)\n #5 /xxx/var/cache/prod/ContainerXrbogn0/CartService_9dde17f.php(38): Eccube\\Service\\CartService->addProduct(Object(Eccube\\Entity\\ProductClass), 1)\n #6 /xxx/src/Eccube/Controller/ProductController.php(761): CartService_9dde17f->addProduct('2')\n #7 /xxx/vendor/symfony/http-kernel/HttpKernel.php(151): Eccube\\Controller\\ProductController->addCart(Object(Symfony\\Component\\HttpFoundation\\Request), Object(Eccube\\Entity\\Product))\n #8 /xxx/vendor/symfony/http-kernel/HttpKernel.php(68): Symfony\\Component\\HttpKernel\\HttpKernel->handleRaw(Object(Symfony\\Component\\HttpFoundation\\Request), 1)\n #9 /xxx/vendor/symfony/http-kernel/Kernel.php(200): Symfony\\Component\\HttpKernel\\HttpKernel->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n #10 /xxx/index.php(76): Symfony\\Component\\HttpKernel\\Kernel->handle(Object(Symfony\\Component\\HttpFoundation\\Request))\n #11 {main}"] [POST, /products/add_cart/141, xxx] |
HelloBetty |
投稿日時: 2021/5/11 11:48
対応状況: 解決済
|
新米 登録日: 2021/2/10 居住地: 投稿: 10 |
Re: Entity has to be managed or scheduled for removal for single computation というエラーについて こちらですが、カートの振り分けをするのに
CartItemComparator でなく CartItemAllocator を実装することで 判別箇所にProductClassが読み込まれていましたので そこに含むようにしていたmaker_idを元に振り分けが出来るようになりました 質問とは違う形でですが解決しましたので〆させて頂ます |
スレッド表示 | 新しいものから | 前のトピック | 次のトピック | トップ |