{"id":1562,"date":"2022-12-17T17:13:05","date_gmt":"2022-12-17T08:13:05","guid":{"rendered":"https:\/\/blog.fourthgate.jp\/?p=1562"},"modified":"2023-07-13T09:55:41","modified_gmt":"2023-07-13T00:55:41","slug":"ec-cube4-2-%e5%90%8c%e4%b8%80%e5%95%86%e5%93%81%e8%a4%87%e6%95%b0%e8%a6%8f%e6%a0%bc%e4%b8%80%e6%8b%ac%e3%82%ab%e3%83%bc%e3%83%88%e6%8a%95%e5%85%a5%e3%82%ab%e3%82%b9%e3%82%bf%e3%83%9e%e3%82%a4%e3%82%ba","status":"publish","type":"post","link":"https:\/\/blog.fourthgate.jp\/?p=1562","title":{"rendered":"EC-CUBE4.2 \u540c\u4e00\u5546\u54c1\u306e\u8907\u6570\u306e\u898f\u683c\u3092\u30ab\u30fc\u30c8\u306b\u4e00\u62ec\u6295\u5165\u3059\u308b\u30ab\u30b9\u30bf\u30de\u30a4\u30ba"},"content":{"rendered":"<p>EC-CUBE4\u306e\u304a\u8a71\u3002<br \/>\n\u30bf\u30a4\u30c8\u30eb\u3060\u3051\u3067\u306f\u308f\u304b\u3089\u306a\u3044\u304b\u3082\u3057\u308c\u306a\u3044\u3067\u3059\u304c\u3001\u4f8b\u3048\u3070\u8863\u6599\u54c1\u306e\u540c\u4e00\u5546\u54c1\u306b\u3064\u3044\u3066\u3001\u30b5\u30a4\u30ba\u9055\u3044\u30fb\u8272\u9055\u3044\u3092\u307e\u3068\u3081\u3066\u30ab\u30fc\u30c8\u306b\u6295\u5165\u3059\u308b\u3068\u3044\u3063\u305f\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u3067\u3059\u3002<br \/>\nEC-CUBE2\u3067\u306f\u7121\u6599\u306e\u30d7\u30e9\u30b0\u30a4\u30f3\u304c\u3042\u308a\u307e\u3059\u304c\u3001EC-CUBE4\u306b\u306f\u898b\u5f53\u305f\u3089\u306a\u304b\u3063\u305f\u306e\u3067\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u3057\u3066\u304f\u308c\u3068\u8a00\u3046\u3054\u8981\u671b\u3067\u3057\u305f\u3002<\/p>\n<p>\u50d5\u81ea\u8eab\u3001EC-CUBE4\u3068\u3044\u3046\u304bsymfony\u306f\u6b86\u3069\u89e6\u3063\u305f\u3053\u3068\u304c\u306a\u304b\u3063\u305f\u306e\u3067\u3001\u305d\u306e\u3078\u3093\u306e\u8abf\u67fb\u304b\u3089\u306b\u306a\u308a\u307e\u3057\u305f\u3002<br \/>\n\u4e00\u756a\u53c2\u8003\u306b\u306a\u3063\u305f\u306e\u306f\u3001\u4ee5\u4e0b\u306e\u30b5\u30a4\u30c8\u3067\u3059\u3002<br \/>\n1) <a href=\"https:\/\/symfonycasts.com\/screencast\/collections\/add-new-collection-prototype\" target=\"_blank\" rel=\"noopener\"><br \/>\nhttps:\/\/symfonycasts.com\/screencast\/collections\/add-new-collection-prototype<\/a><br \/>\n2) <a href=\"https:\/\/symfony.com\/doc\/current\/reference\/forms\/types\/collection.html\" target=\"_blank\" rel=\"noopener\">https:\/\/symfony.com\/doc\/current\/reference\/forms\/types\/collection.html<\/a><\/p>\n<p>\u540c\u6642\u306b\u8907\u6570\u306e\u5546\u54c1\u3092\u30ab\u30fc\u30c8\u306b\u5165\u308c\u308b\u305f\u3081\u306b\u306f\u3001AddCartType\u3092\u8907\u6570\u914d\u7f6e\u3059\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<br \/>\nsymfony\u306e\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u306b\u3088\u308b\u3068\u3001\u3072\u3068\u3064\u306e\u30d5\u30a9\u30fc\u30e0\u3067\u8907\u6570\u306eentity\u3092\u6271\u3048\u308b\u3088\u3046\u306b\u3059\u308b\u306b\u306f\u3001CollectionType\u3092\u4f7f\u3048\u3068\u3044\u3046\u3053\u3068\u3067\u3057\u305f\u3002<br \/>\nEC-CUBE4\u3067\u30ab\u30fc\u30c8\u306b\u5546\u54c1\u3092\u6295\u5165\u3059\u308b\u30d5\u30a9\u30fc\u30e0\u30bf\u30a4\u30d7\u306f\u3001<br \/>\nsrc\/Eccube\/Form\/Type\/AddCartType.php<br \/>\n\u3067\u3059\u3002<br \/>\n\u3053\u308c\u3092CollectionType\u3092\u4f7f\u3063\u3066\u3001\u8907\u6570\u6271\u3048\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<p>src\/Eccube\/Controller\/ProductController.php<br \/>\n\u3092\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u306e\u3067<br \/>\napp\/Customize\/Controller\/<br \/>\n\u4e0b\u306b\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<br \/>\nfunction detail()\u3092\u30aa\u30ea\u30b8\u30ca\u30eb\u304b\u3089\u30b3\u30d4\u30fc\u3057\u3066\u3001\u30d5\u30a9\u30fc\u30e0\u30d3\u30eb\u30c0\u30fc\u90e8\u5206\u3092<\/p>\n<pre>$builder = $this-&gt;formFactory-&gt;createBuilder( );\n$builder\n    -&gt;add(\n        'data',\n        CollectionType::class,\n        [\n            'entry_type' =&gt; AddCartType::class,\n            'entry_options' =&gt; [\n                'product' =&gt; $Product,\n                'id_add_product_id' =&gt; false,\n                'attr' =&gt; ['class' =&gt; 'oneclass'],\n            ],\n            'allow_add' =&gt; true,\n            'allow_delete' =&gt; true,\n            'label' =&gt; '',\n        ]\n    );\n<\/pre>\n<p>\u306e\u3088\u3046\u306b\u3057\u307e\u3059\u3002<br \/>\n\u307e\u305f\u3001twig\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8<br \/>\nsrc\/Eccube\/Resource\/template\/default\/Product\/detail.twig<br \/>\n\u3092\u3001<br \/>\napp\/template\/default\/Product<br \/>\n\u306b\u30b3\u30d4\u30fc\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u72b6\u614b\u3067\u3001<br \/>\n\/products\/detail\/xxxx<br \/>\n\u306b\u30a2\u30af\u30bb\u30b9\u3057\u3066\u3001\u5909\u6570form\u3092\u30c0\u30f3\u30d7\u3059\u308b\u3068\u3001<\/p>\n<pre>children-&gt;data-&gt;vars-&gt;prototype<\/pre>\n<p>\u306e\u4e2d\u306b\u3001AddCartType\u306e\u8981\u7d20\u304c\u305a\u3089\u305a\u3089\u301c\u3068\u5165\u3063\u3066\u3044\u308b\u306f\u305a\u3067\u3059\u3002<\/p>\n<p>detail.twig\u306eadd_cart\u306e\u30d5\u30a9\u30fc\u30e0\u306e\u4e2d\u306b\u3001\u4e0a\u8a181)\u306eURL\u306b\u3042\u308b\u3088\u3046\u306b\u3001<\/p>\n<pre>&lt;div class=\"product-class-item\" data-prototype=\"{{ form_widget(form.data.vars.prototype)|e('html_attr') }}\"&gt;&lt;\/div-&gt;<\/pre>\n<p>\u3092\u8ffd\u52a0\u3059\u308b\u3068\u3001data-prototype\u306e\u90e8\u5206\u306b\u3001\u6570\u91cf\u3068\u898f\u683c\u306e\u9078\u629e\u90e8\u5206\u306ehtml\u304c\u5410\u304d\u51fa\u3055\u308c\u3066\u3044\u307e\u3059\u3002<br \/>\n\u3053\u306e\u90e8\u5206\u306b\u306f\u3001<\/p>\n<p>\u3053\u308c\u307e\u305f1)\u3092\u53c2\u8003\u306b\u3001\u8ffd\u52a0\u524a\u9664\u30dc\u30bf\u30f3\u3092\u51e6\u7406\u3059\u308bJavaScript\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<br \/>\n\uff08\u50d5\u306e\u66f8\u3044\u305f\u30b3\u30fc\u30c9\u3001\u76f8\u5f53\u30ab\u30c3\u30b3\u60aa\u3044\u3068\u611f\u3058\u3066\u3044\u308b\u306e\u3067\u3053\u3053\u306b\u306f\u8f09\u305b\u307e\u305b\u3093\uff09<br \/>\n\u305d\u3046\u3059\u308b\u3068\u3001<\/p>\n<pre>&lt;div id=\"form_data_X\" class=\"oneclass\"&gt;\u301c&lt;\/div&gt;<\/pre>\n<p>\u3067\u56f2\u308f\u308c\u305f\u3001\u4e00\u3064\u306e\u5546\u54c1\u898f\u683c\u9078\u629e\u30d5\u30a9\u30fc\u30e0\u8981\u7d20\u304c\u8ffd\u52a0\u3055\u308c\u307e\u3059\u3002<br \/>\n\u30d5\u30a9\u30fc\u30e0\u306e\u8981\u7d20\u306ename\u306f\u3001form[data][0][quantity]\u306e\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u308b\u3068\u601d\u3044\u307e\u3059\u3002<br \/>\n\u3053\u308c\u3067\u3001\u8907\u6570\u306e\u898f\u683c\u3092\u30ab\u30fc\u30c8\u306b\u6295\u5165\u3059\u308b\u3068\u3001\u914d\u5217\u3068\u3057\u3066\u9001\u4fe1\u3055\u308c\u307e\u3059\u3002<br \/>\n\u306a\u304a\u3001\u30ab\u30fc\u30c8\u8ffd\u52a0\u306eaction\u306fproducts\/addmulti_cart\u306b\u3057\u307e\u3057\u305f\u3002<br \/>\n\u5546\u54c1\u4e00\u89a7\uff08\/products\/list\uff09\u306e\u307b\u3046\u3067\/products\/add_cart\u306f\u4f7f\u3046\u304b\u3082\u3057\u308c\u306a\u3044\u306e\u3067\u3001\u30a2\u30af\u30b7\u30e7\u30f3\u3092\u5206\u3051\u3066\u304a\u3044\u305f\u307b\u3046\u304c\u697d\u304b\u306a\u3068\u601d\u3044\u307e\u3057\u305f\u306e\u3067\u3002<\/p>\n<p>ProductController.php\u306efunction addCart\u3082\u30b3\u30d4\u30fc\u3057\u3066\u3001function addmultiCart()\u3068\u3057\u3066\u30ab\u30fc\u30c8\u3078\u8ffd\u52a0\u3059\u308b\u51e6\u7406\u3092\u8a18\u8ff0\u3057\u307e\u3059\u3002<br \/>\n\u30d5\u30a9\u30fc\u30e0\u30d3\u30eb\u30c0\u30fc\u306e\u3068\u3053\u308d\u306ffunction detail\u3068\u540c\u3058\u3067\u3059\u3002<\/p>\n<p>\u30a8\u30e9\u30fc\u304c\u306a\u3051\u308c\u3070\u3001$form-&gt;getData() \u306b\u306f\u30ab\u30fc\u30c8\u306b\u5165\u308c\u308b\u5546\u54c1\u6bce\u306e\u914d\u5217\u304c\u5165\u3063\u3066\u3044\u307e\u3059\u3002<br \/>\n\u3053\u3053\u306f\u3001<\/p>\n<pre>foreach ( $addCartData['data'] as $oneItem ) {\n    $this-&gt;cartService-&gt;addProduct($oneItem['product_class_id'], $oneItem['quantity']);\n}\n<\/pre>\n<p>\u3068\u30eb\u30fc\u30d7\u3092\u56de\u3057\u3066\u3001\u3072\u3068\u3064\u305a\u3064\u30ab\u30fc\u30c8\u306b\u8ffd\u52a0\u3059\u308b\u3088\u3046\u306b\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u3082\u3046\u3061\u3087\u3063\u3068\u3001\u30b7\u30e5\u30c3\u3068\u3057\u305f\u3084\u308a\u304b\u305f\u304c\u3042\u308b\u3088\u3046\u304c\u3042\u308b\u3068\u601d\u3044\u307e\u3059\u304c\u3001\u3068\u308a\u3042\u3048\u305a\u52d5\u3044\u305f\u306e\u3067OK\u3068\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u306a\u304a\u3001symfony\u304c\u306a\u306e\u304b\u3001CollectionType\u304c\u306a\u306e\u304b\u308f\u304b\u308a\u307e\u305b\u3093\u304c\u3001\u30e1\u30e2\u30ea\u30fc\u3092\u304b\u306a\u308a\u4f7f\u3046\u3088\u3046\u3067\u3059\u3002<br \/>\n\u50d5\u304c\u8a66\u3057\u305fubuntu22.04\uff08PHP8.1\uff09\u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u306ememory_limit\u3067\u306f\u30e1\u30e2\u30ea\u30fc\u4e0d\u8db3\u306b\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3057\u305f\u3002<br \/>\nmemory_limit\u3092512M\u306b\u3057\u305f\u3089\u30a8\u30e9\u30fc\u306f\u8d77\u304d\u306a\u304f\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<p>\u203b\u73fe\u5728\u3001\u7d76\u8cdb\u304a\u4ed5\u4e8b\u52df\u96c6\u4e2d\u3067\u3059\u3002\u8208\u5473\u3092\u304a\u6301\u3061\u306e\u304b\u305f\u306f\u3001\u4ee5\u4e0b\u306e\u554f\u3044\u5408\u308f\u305b\u30d5\u30a9\u30fc\u30e0\u304b\u3089<br \/>\n<a href=\"https:\/\/www.fourthgate.jp\/index.php\/contact\/\" target=\"_blank\" rel=\"noopener\">https:\/\/www.fourthgate.jp\/index.php\/contact\/<\/a><br \/>\n\u304b\u3089\u3001\u662f\u975e\u662f\u975e\u3054\u9023\u7d61\u304f\u3060\u3055\u3044\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>EC-CUBE4\u306e\u304a\u8a71\u3002 \u30bf\u30a4\u30c8\u30eb\u3060\u3051\u3067\u306f\u308f\u304b\u3089\u306a\u3044\u304b\u3082\u3057\u308c\u306a\u3044\u3067\u3059\u304c\u3001\u4f8b\u3048\u3070\u8863\u6599\u54c1\u306e\u540c\u4e00\u5546\u54c1\u306b\u3064\u3044\u3066\u3001\u30b5\u30a4\u30ba\u9055\u3044\u30fb\u8272\u9055\u3044\u3092\u307e\u3068\u3081\u3066\u30ab\u30fc\u30c8\u306b\u6295\u5165\u3059\u308b\u3068\u3044\u3063\u305f\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u3067\u3059\u3002 EC-CUBE2\u3067\u306f\u7121\u6599\u306e\u30d7\u30e9\u30b0\u30a4\u30f3\u304c\u3042\u308a\u307e &hellip; <a href=\"https:\/\/blog.fourthgate.jp\/?p=1562\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[5],"tags":[],"class_list":["post-1562","post","type-post","status-publish","format-standard","hentry","category-web"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/blog.fourthgate.jp\/index.php?rest_route=\/wp\/v2\/posts\/1562","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.fourthgate.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.fourthgate.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.fourthgate.jp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.fourthgate.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1562"}],"version-history":[{"count":13,"href":"https:\/\/blog.fourthgate.jp\/index.php?rest_route=\/wp\/v2\/posts\/1562\/revisions"}],"predecessor-version":[{"id":1616,"href":"https:\/\/blog.fourthgate.jp\/index.php?rest_route=\/wp\/v2\/posts\/1562\/revisions\/1616"}],"wp:attachment":[{"href":"https:\/\/blog.fourthgate.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1562"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.fourthgate.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1562"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.fourthgate.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1562"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}