01.11.10

Magento – Customize Order Management Workflow

Posted in Magento at 5:25 pm by alewo

Eines der größten Probleme bei Magento ist leider der fest vorgegebene Workflow. Der Besteht standardmäßig ja aus den Statuus “Pending, Hold, Processing, Canceled, Complete und Closed” und unterscheidet zwischen online und offline-Payment. Leider bilden diese Statuus nie wirklich jeden Workflow ab und eigentlich wäre es sowieso schöner, wenn man sich diesen Workflow gestalten könnte, wie man sich es wünscht. Eine recht anschauliche grafische Darstellung des Workflows habe ich hier gefunden.

Ich habe mich jetzt noch nicht im Detail mit der Umsetzung beschäftigt, aber am Ende habe ich mir zum Ziel gesetzt, soll mein Wunschworkflow so aussehen:

wunsch-workflow

Selbstverständlich soll jede dieser Stufen in dem Workflow noch einzelne Unterstufen enthalten können. Also mal los, mal schauen obs was wird.

Als erste habe ich mal mit dem Order_Status Plugin rumgespielt, was allerdings nicht die mir gewünschte Funktionalität beinhaltet bzw. bei mir nicht so funktioniert hat, wie es funktionieren sollte. Also hab ich das jetzt mal wieder deinstalliert und versuch es auf eigene Faust =) . Mit dem durch das Order_Status-Plugin gewonnen Vorwissen, wird es hoffentlich ein wenig einfacher…

Als erstes habe ich mich einmal auf die Suche gemacht, nach einer Möglichkeit, den Workflow zu ändern. Also neue Verknüpfungen zwischen den bereits bestehenden Statuus zu finden. Und Voila, fündig geworden bin ich in “app\code\core\Mage\Sales\etc\config.xml” ab etwa Zeile 544.

544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
<order>
  <statuses>
    <pending translate="label"><label>Pending</label></pending>
    <pending_paypal translate="label"><label>Pending PayPal</label></pending_paypal>
    <processing translate="label"><label>Processing</label></processing>
    <holded translate="label"><label>On Hold</label></holded>
    <complete translate="label"><label>Complete</label></complete>
    <closed translate="label"><label>Closed</label></closed>
    <canceled translate="label"><label>Canceled</label></canceled>
  </statuses>
  <states>
    <new translate="label">
        <label>New</label>
        <statuses>
            <pending/>
        </statuses>
        <visible_on_front/>
    </new>
    <pending_payment translate="label">
        <label>Pending Payment</label>
        <statuses>
            <pending_paypal/>
        </statuses>
    </pending_payment>
    <processing translate="label">
        <label>Processing</label>
        <statuses>
            <processing/>
        </statuses>
        <visible_on_front/>
    </processing>
    <complete translate="label">
        <label>Complete</label>
        <statuses>
            <complete/>
        </statuses>
        <visible_on_front/>
    </complete>
    <closed translate="label">
        <label>Closed</label>
        <statuses>
            <closed/>
        </statuses>
        <visible_on_front/>
    </closed>
    <canceled translate="label">
        <label>Canceled</label>
        <statuses>
            <canceled/>
        </statuses>
        <visible_on_front/>
    </canceled>
    <holded translate="label">
        <label>On Hold</label>
        <statuses>
            <holded/>
        </statuses>
        <visible_on_front/>
    </holded>
  </states>
</order>

Hier habe ich einfach mal jedem Status jeden anderen Status als übergang zugeordnet, um zu sehen ob der gewünschte Vorgang eintritt.

Das Resultat sah dann also folgendermaßen aus:

544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
<order>
  <statuses>
    <pending translate="label"><label>Pending</label></pending>
    <pending_paypal translate="label"><label>Pending PayPal</label></pending_paypal>
    <processing translate="label"><label>Processing</label></processing>
    <holded translate="label"><label>On Hold</label></holded>
    <complete translate="label"><label>Complete</label></complete>
    <closed translate="label"><label>Closed</label></closed>
    <canceled translate="label"><label>Canceled</label></canceled>
  </statuses>
  <states>
    <new translate="label">
        <label>New</label>
        <statuses>
            <pending/>
            <pending_paypal/>
            <processing/>
            <complete/>
            <closed/>
            <canceled/>
            <holded/>
        </statuses>
        <visible_on_front/>
    </new>
    <pending_payment translate="label">
        <label>Pending Payment</label>
        <statuses>
            <pending/>
            <pending_paypal/>
            <processing/>
            <complete/>
            <closed/>
            <canceled/>
            <holded/>
        </statuses>
    </pending_payment>
    <processing translate="label">
        <label>Processing</label>
        <statuses>
            <pending/>
            <pending_paypal/>
            <processing/>
            <complete/>
            <closed/>
            <canceled/>
            <holded/>
        </statuses>
        <visible_on_front/>
    </processing>
    <complete translate="label">
        <label>Complete</label>
        <statuses>
            <pending/>
            <pending_paypal/>
            <processing/>
            <complete/>
            <closed/>
            <canceled/>
            <holded/>
        </statuses>
        <visible_on_front/>
    </complete>
    <closed translate="label">
        <label>Closed</label>
        <statuses>
            <pending/>
            <pending_paypal/>
            <processing/>
            <complete/>
            <closed/>
            <canceled/>
            <holded/>
        </statuses>
        <visible_on_front/>
    </closed>
    <canceled translate="label">
        <label>Canceled</label>
        <statuses>
            <pending/>
            <pending_paypal/>
            <processing/>
            <complete/>
            <closed/>
            <canceled/>
            <holded/>
        </statuses>
        <visible_on_front/>
    </canceled>
    <holded translate="label">
        <label>On Hold</label>
        <statuses>
            <pending/>
            <pending_paypal/>
            <processing/>
            <complete/>
            <closed/>
            <canceled/>
            <holded/>
        </statuses>
        <visible_on_front/>
    </holded>
  </states>
</order>

Ein Test im Adminbereich bestätigt das funktionieren der Änderung. Unabhängig vom gesetzten Status der Bestellung, kann ich nun im Kommentarlauf jeden Beliebigen anderen Status setzen.

Überzeugt von diesem ersten Erfolg, will ich nun als nächstes einmal einen neuen Status mit Übergängen zu den anderen erstellen.
Ich erweitere den Code also um einen Zustand “Test”.

<order>
  <statuses>
    ...
    <test translate="label"><label>Test</label></test>
  </statuses>
  <states>
    ...
    <test translate="label">
        <label>test</label>
        <statuses>
            <test/>
            <pending/>
            <pending_paypal/>
            <processing/>
            <complete/>
            <closed/>
            <canceled/>
            <holded/>
        </statuses>
        <visible_on_front/>
    </test>
    ...
  </states>
</order>

Da nun auch der neue Testzustand wunschgemäß arbeitet, mach ich mich nun mal an den ersten richtig großen Schritt, ich erstelle alle Statuus, die ich in meinem Workflow haben möchte und entferne die unnötigen =).

Es ergab sich also folgender Inhalt…

544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
           <order>
                <statuses>
                    <pending translate="label"><label>Pending</label></pending>
                    <processing translate="label"><label>Processing</label></processing>
                    <distributed translate="label"><label>Versendet</label></distributed>
                    <complete translate="label"><label>Fertig</label></complete>
                    <retour translate="label"><label>Closed</label></retour>
                    <canceled translate="label"><label>Canceled</label></canceled>
		<correction translate="label"><label>Korrektur</label></correction>
                </statuses>
                <states>
                    <new translate="label">
                        <label>New</label>
                        <statuses>
			<pending/>
			<processing/>
			<distributed/>
			<complete/>
			<retour/>
			<correction/>
			<canceled/>
                        </statuses>
                        <visible_on_front/>
                    </new>
                    <pending translate="label">
                        <label>Pending</label>
                        <statuses>
			<pending/>
			<processing/>
			<canceled/>
                        </statuses>
                        <visible_on_front/>
                    </pending>
                    <processing translate="label">
                        <label>Processing</label>
                        <statuses>
			<processing/>
			<distributed/>
                        </statuses>
                        <visible_on_front/>
                    </processing>
                    <distributed translate="label">
                        <label>Versendet</label>
                        <statuses>
			<distributed/>
			<complete/>
			<retour/>
                        </statuses>
                        <visible_on_front/>
                    </distributed>
                    <complete translate="label">
                        <label>Fertig</label>
                        <statuses>
			<complete/>
			<retour/>
			<canceled/>
                        </statuses>
                        <visible_on_front/>
                    </complete>
                    <retour translate="label">
                        <label>Retour</label>
                        <statuses>
			<retour/>
			<correction/>
                        </statuses>
                        <visible_on_front/>
                    </retour>
                    <correction translate="label">
                        <label>Korrektur</label>
                        <statuses>
			<correction/>
			<processing/>
			<canceled/>
                        </statuses>
                        <visible_on_front/>
                    </correction>
                    <canceled translate="label">
                        <label>Canceled</label>
                        <statuses>
			<canceled/>
			<pending/>
                        </statuses>
                        <visible_on_front/>
                    </canceled>
                </states>
            </order>

nachdem nun auch dieser veränderte Workflow seine Arbeit getan hat, hat mich nun mein Größenwahn gepackt. Ich hab mir gedacht, wenn ich den Workflow Grob nachbilden kann, warum dann nicht auch im Detail. Also nächstes Ziel soll sein, diesen ersten Detailierten Workflow abzubilden:
Detailierter Workflow

Da mir im Moment die Zeit fehlt rumzuexperimentieren, werde ich das Ganze im Auge behalten und bei Gelegenheit umsetzen. Dann werde ich hier natürlich drüber berichten…

1 Comment »

  1. Benjamin Wunderlich said,

    October 18, 2011 at 9:23 am

    Hi,

    schöne Vorüberlegungen. Hast du das Thema noch weiter verfolgt? Die Order-States lassen sich ja in den neueren Magento-Versionen zumindest schon einmal über das Backend konfigurieren. Mich interessiert primär die flexible Anpassung des Workflows. Falls es hierzu noch kein ordentliches Modul gibt, würde ich sowas sonst auch mal angehen.

    Viele Grüße,
    Benjamin

Leave a Comment

You must be logged in to post a comment.