PageSourceSearch

https://docs.coreshop.com/assets/js/a941176e.6e88febc.js

js coreshop.com collected 2026-10-10 00:36:18 UTC 6,224 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunkcoreshop_docs=self.webpackChunkcoreshop_docs||[]).push([[5779],{1387:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>p,contentTitle:()=>a,default:()=>h,frontMatter:()=>o,metadata:()=>r,toc:()=>c});const r=JSON.parse('{"id":"CoreShop/Development/Order/Backend_Management/OrderList_Action","title":"Order List Actions","description":"Actions allows you to process orders rapidly, right in the order grid view.","source":"@site/versioned_docs/version-5.1/01_CoreShop/03_Development/06_Order/14_Backend_Management/02_OrderList_Action.md","sourceDirName":"01_CoreShop/03_Development/06_Order/14_Backend_Management","slug":"/CoreShop/Development/Order/Backend_Management/OrderList_Action","permalink":"/5.1/CoreShop/Development/Order/Backend_Management/OrderList_Action","draft":false,"unlisted":false,"tags":[],"version":"5.1","sidebarPosition":2,"frontMatter":{},"sidebar":"defaultSidebar","previous":{"title":"Order List Filter","permalink":"/5.1/CoreShop/Development/Order/Backend_Management/OrderList_Filter"},"next":{"title":"Extending Order Detail","permalink":"/5.1/CoreShop/Development/Order/Backend_Management/Extend_OrderDetail"}}');var s=t(74848),i=t(28453);const o={},a="Order List Actions",p={},c=[{value:"Register Filter Service",id:"register-filter-service",level:2},{value:"Create PHP Class",id:"create-php-class",level:2}];function d(e){const n={code:"code",h1:"h1",h2:"h2",header:"header",img:"img",p:"p",pre:"pre",...(0,i.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.header,{children:(0,s.jsx)(n.h1,{id:"order-list-actions",children:"Order List Actions"})}),"\n",(0,s.jsx)(n.p,{children:"Actions allows you to process orders rapidly, right in the order grid view."}),"\n",(0,s.jsx)(n.p,{children:(0,s.jsx)(n.img,{src:"http://g.recordit.co/QCN7emXQ8L.gif",alt:"filter"})}),"\n",(0,s.jsx)(n.h2,{id:"register-filter-service",children:"Register Filter Service"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-yml",children:"App\\CoreShop\\OrderList\\Action\\Demo:\n    arguments:\n        $stateMachineManager: '@coreshop.state_machine_manager'\n        $shipmentRepository: '@coreshop.repository.order_shipment'\n    tags:\n        - { name: coreshop.grid.action, type: demo }\n"})}),"\n",(0,s.jsx)(n.h2,{id:"create-php-class",children:"Create PHP Class"}),"\n",(0,s.jsx)(n.p,{children:'In this example we want to apply the shipment transition "ship" to selected orders.'}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-php",children:"<?php\n\nnamespace App\\CoreShop\\OrderList\\Action;\n\nuse CoreShop\\Component\\Order\\Repository\\OrderShipmentRepositoryInterface;\nuse CoreShop\\Bundle\\WorkflowBundle\\Manager\\StateMachineManagerInterface;\nuse CoreShop\\Component\\Pimcore\\DataObject\\Grid\\GridActionInterface;\nuse Pimcore\\Model\\DataObject\\CoreShopOrder;\n\nclass DemoAction implements GridActionInterface\n{\n    protected $stateMachineManager;\n\n    protected $shipmentRepository;\n\n    public function __construct(\n        StateMachineManagerInterface $stateMachineManager,\n        OrderShipmentRepositoryInterface $shipmentRepository\n    ) {\n        $this->stateMachineManager = $stateMachineManager;\n        $this->shipmentRepository = $shipmentRepository;\n    }\n\n    public function getName(): string\n    {\n        return 'coreshop.order.demo';\n    }\n\n    public function apply(array $processIds): string\n    {\n        $message = '';\n        $transition = 'ship';\n        $shipmentIds = [];\n\n        foreach ($processIds as $id) {\n\n            $m = [];\n            $order = CoreShopOrder::getById($id);\n            $shipments = $this->shipmentRepository->getDocuments($order);\n\n            if (count($shipments) === 0) {\n                $m[] = sprintf('- no shipments for order %s found. skipping....', $order->getId());\n            } else {\n                foreach ($shipments as $shipment) {\n                    if ($shipment->getState() === 'shipped') {\n                        $m[] = sprintf('- transition \"%s\" for shipment %s already applied. skipping...', $transition, $shipment->getId());\n                        continue;\n                    }\n                    $workflow = $this->stateMachineManager->get($shipment, 'coreshop_shipment');\n                    if (!$workflow->can($shipment, $transition)) {\n                        $m[] = sprintf('- transition \"%s\" for shipment %s not allowed.', $transition, $shipment->getId());\n                    } else {\n                        try {\n                            $workflow->apply($shipment, $transition);\n                            $shipmentIds[] = $shipment->getId();\n                            $m[] = sprintf('- transition \"%s\" for shipment id %s successfully applied.', $transition, $shipment->getId());\n                        } catch (\\Exception $e) {\n                            $m[] = sprintf('- error while applying transition \"%s\" to shipment with id %s: %s.', $transition, $shipment->getId(), $e->getMessage());\n                        }\n                    }\n                }\n            }\n\n            $message .= sprintf('<strong>Order %s:</strong><br>%s<br>', $id, join('<br>', $m));\n\n        }\n\n        if (count($shipmentIds) > 0) {\n            $packingListUrl = '/admin/your-packing-list-generator-url?ids=' . join(',', $shipmentIds);\n            $message .= sprintf('<br><a href=\"%s\" target=\"_blank\">%s</a><br>', $packingListUrl, 'packing list');\n        }\n\n        return $message;\n    }\n\n    public function supports(string $listType): bool\n    {\n        return $listType === 'coreshop_order';\n    }\n}\n"})})]})}function h(e={}){const{wrapper:n}={...(0,i.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(d,{...e})}):d(e)}},28453:(e,n,t)=>{t.d(n,{R:()=>o,x:()=>a});var r=t(96540);const s={},i=r.createContext(s);function o(e){const n=r.useContext(i);return r.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function a(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:o(e.components),r.createElement(i.Provider,{value:n},e.children)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.