Dieses System wurde erstellt, um ein Tofex Modul zu präsentieren. Eine Anleitung, wie das System verwendet werden kann, ist unter diesem Link zu finden.
Die Dokumentation des Moduls ist unter diesem Link zu finden.

Dies ist eine Demo-Installation. Jegliche Bestellung in diesem Shop wird weder beachtet noch ausgeführt.

Tofex Sales Jobs

Introduction

This extension is a base module to use when sales objects have to created with external data.

Concept

If orders in Magento are handled by an external system like an ERP and you still want to have a complete process in Magento, it is required to generate the necessary Magento objects using data from the external system without any generation triggered in the Magento backend. This means shipment, tracking, invoice and credit memo have to be prepared programmatically. This extension provides an easy handling of this.

The extension contains four processes in the form of abstract classes which you have to implement and provide the necessary date. There are also some entry points available during the process which can be used for further implementation or left alone.

The four processes are:

  • Customer notification when order state / status reached
  • Creating of shipment with tracking
  • Creating of invoice
  • Creating of credit memo

Development

Customer notification

This job sends a notification to the customer in case the order has reached a certain status without any Magento logic being involved.

  • getStateStatus: List of order state / status to check for
  • getOrdersLimit: Limit the number of orders processing
  • prepareCollection: In case you want to change the collection to identify the orders
  • canProcessOrder: In case you want to provide some more checking with the loaded order
  • getStatusHistoryComment: The comment to use in the order status history
  • getIsVisibleOnFront: If the added order status history is visible
  • prepareOrder: Update the order before saving
  • followUpOrder: For additional processes after the order was saved
  • canNotifyCustomer: If the customer can be notified about the change
<?php

class Webshop_SalesJobs_Model_Notification
    extends Tofex_SalesJobs_Model_Notification
{
    /**
     * key: state
     * value: status
     *
     * @return string[]
     */
    protected function getStateStatus()
    {
        ...
    }

    /**
     * @return int
     */
    protected function getOrdersLimit()
    {
        ...
    }

    /**
     * @param Mage_Sales_Model_Resource_Order_Collection $collection
     */
    protected function prepareCollection(Mage_Sales_Model_Resource_Order_Collection $collection)
    {
        ...
    }

    /**
     * @param Mage_Sales_Model_Order $order
     * @param string                 $state
     * @param string                 $status
     *
     * @return bool
     */
    protected function canProcessOrder(Mage_Sales_Model_Order $order, $state, $status)
    {
        ...
    }

    /**
     * @param Mage_Sales_Model_Order $order
     * @param string                 $state
     * @param string                 $status
     *
     * @return string
     */
    protected function getStatusHistoryComment(Mage_Sales_Model_Order $order, $state, $status)
    {
        ...
    }

    /**
     * @param Mage_Sales_Model_Order $order
     * @param string                 $state
     * @param string                 $status
     *
     * @return bool
     */
    protected function getIsVisibleOnFront(Mage_Sales_Model_Order $order, $state, $status)
    {
        ...
    }

    /**
     * @param Mage_Sales_Model_Order $order
     */
    protected function prepareOrder(Mage_Sales_Model_Order $order)
    {
        ...
    }

    /**
     * @param Mage_Sales_Model_Order $order
     */
    protected function followUpOrder(Mage_Sales_Model_Order $order)
    {
        ...
    }

    /**
     * @param Mage_Sales_Model_Order $order
     * @param string                 $state
     * @param string                 $status
     *
     * @return bool
     */
    protected function canNotifyCustomer(Mage_Sales_Model_Order $order, $state, $status)
    {
        ...
    }
}

Creating shipment / tracking

This job creates a shipment with tracking information. There can be multiple tracks. Customer can be notified about the shipment if required.

  • getOrdersLimit: Limit the number of orders processing
  • prepareCollection: In case you want to change the collection to identify the orders
  • canProcessOrder: In case you want to provide some more checking with the loaded order
  • getShipmentQtys: Which items in what amount where shipped
  • getTrackingIds: List of tracking ids, each creates a track
  • getTrackNumber: The number of the track
  • getTrackCarrierCode: The carrier code of the track
  • getTrackTitle: The title of the track
  • prepareOrder: Update the order before saving
  • followUpOrder: For additional processes after the order was saved
  • canSendShipment: If the customer can be notified
<?php

class Webshop_SalesJobs_Model_Shipment
    extends Tofex_SalesJobs_Model_Shipment
{
    /**
     * @return int
     */
    protected function getOrdersLimit()
    {
        ...
    }

    /**
     * @param Mage_Sales_Model_Resource_Order_Collection $collection
     */
    protected function prepareCollection(Mage_Sales_Model_Resource_Order_Collection $collection)
    {
        ...
    }

    /**
     * @param Mage_Sales_Model_Order $order
     *
     * @return bool
     */
    protected function canProcessOrder(Mage_Sales_Model_Order $order)
    {
        ...
    }

    /**
     * @param Mage_Sales_Model_Order $order
     *
     * @return array
     */
    protected function getShipmentQtys(Mage_Sales_Model_Order $order)
    {
        ...
    }

    /**
     * @param Mage_Sales_Model_Order $order
     *
     * @return array
     */
    protected function getTrackingIds(Mage_Sales_Model_Order $order)
    {
        ...
    }

    /**
     * @param Mage_Sales_Model_Order $order
     * @param int                    $index
     * @param string                 $trackingId
     *
     * @return string
     */
    protected function getTrackNumber(Mage_Sales_Model_Order $order, $index, $trackingId)
    {
        ...
    }

    /**
     * @param Mage_Sales_Model_Order $order
     * @param int                    $index
     * @param string                 $trackingId
     *
     * @return string
     */
    protected function getTrackCarrierCode(Mage_Sales_Model_Order $order, $index, $trackingId)
    {
        ...
    }

    /**
     * @param Mage_Sales_Model_Order $order
     * @param int                    $index
     * @param string                 $trackingId
     *
     * @return string
     */
    protected function getTrackTitle(Mage_Sales_Model_Order $order, $index, $trackingId)
    {
        ...
    }

    /**
     * @param Mage_Sales_Model_Order $order
     */
    protected function prepareOrder(Mage_Sales_Model_Order $order)
    {
        ...
    }

    /**
     * @param Mage_Sales_Model_Order $order
     */
    protected function followUpOrder(Mage_Sales_Model_Order $order)
    {
        ...
    }

    /**
     * @param Mage_Sales_Model_Order $order
     *
     * @return bool
     */
    protected function canSendShipment(Mage_Sales_Model_Order $order)
    {
        ...
    }
}

Creating invoice

This job creates an invoice. Customer can be notified about the invoice if required.

  • getOrdersLimit: Limit the number of orders processing
  • prepareCollection: In case you want to change the collection to identify the orders
  • canProcessOrder: In case you want to provide some more checking with the loaded order
  • getInvoiceIncrementId: The number of the invoice to create
  • getInvoiceQtys: Which items in what amount have to be invoiced
  • prepareOrder: Update the order before saving
  • followUpOrder: For additional processes after the order was saved
  • canSendInvoice: If the customer can be notified
<?php

class Webshop_SalesJobs_Model_Invoice
    extends Tofex_SalesJobs_Model_Invoice
{
    /**
     * @return int
     */
    protected function getOrdersLimit()
    {
        ...
    }

    /**
     * @param Mage_Sales_Model_Resource_Order_Collection $collection
     */
    protected function prepareCollection(Mage_Sales_Model_Resource_Order_Collection $collection)
    {
        ...
    }

    /**
     * @param Mage_Sales_Model_Order $order
     *
     * @return bool
     */
    protected function canProcessOrder(Mage_Sales_Model_Order $order)
    {
        ...
    }

    /**
     * @param Mage_Sales_Model_Order $order
     *
     * @return string
     */
    protected function getInvoiceIncrementId(Mage_Sales_Model_Order $order)
    {
        ...
    }

    /**
     * @param Mage_Sales_Model_Order $order
     *
     * @return array
     */
    protected function getInvoiceQtys(Mage_Sales_Model_Order $order)
    {
        ...
    }

    /**
     * @param Mage_Sales_Model_Order $order
     */
    protected function prepareOrder(Mage_Sales_Model_Order $order)
    {
        ...
    }

    /**
     * @param Mage_Sales_Model_Order $order
     */
    protected function followUpOrder(Mage_Sales_Model_Order $order)
    {
        ...
    }

    /**
     * @param Mage_Sales_Model_Order $order
     *
     * @return bool
     */
    protected function canSendInvoice(Mage_Sales_Model_Order $order)
    {
        ...
    }
}

Creating credit memo

This job creates a credit memo. Customer can be notified about the credit memo if required.

  • getOrdersLimit: Limit the number of orders processing
  • prepareCollection: In case you want to change the collection to identify the orders
  • canProcessOrder: In case you want to provide some more checking with the loaded order
  • getCreditMemoIncrementId: The number of the credit memo to create
  • getCreditMemoQtys: Which items in what amount have to be credited
  • getCreditMemoShippingAmount: In case an amount of the shipped amount should be credited
  • getCreditMemoAdjustmentPositive: In case a positive adjustment should be added
  • getCreditMemoAdjustmentNegative: In case a negative adjustment (fee) should be added
  • prepareOrder: Update the order before saving
  • followUpOrder: For additional processes after the order was saved
  • canSendCreditMemo: If the customer can be notified
<?php

class Webshop_SalesJobs_Model_Creditmemo
    extends Tofex_SalesJobs_Model_Creditmemo
{
    /**
     * @return int
     */
    protected function getOrdersLimit()
    {
        ...
    }

    /**
     * @param Mage_Sales_Model_Resource_Order_Collection $collection
     */
    protected function prepareCollection(Mage_Sales_Model_Resource_Order_Collection $collection)
    {
        ...
    }

    /**
     * @param Mage_Sales_Model_Order $order
     *
     * @return bool
     */
    protected function canProcessOrder(Mage_Sales_Model_Order $order)
    {
        ...
    }

    /**
     * @param Mage_Sales_Model_Order $order
     *
     * @return string
     */
    protected function getCreditMemoIncrementId(Mage_Sales_Model_Order $order)
    {
        ...
    }

    /**
     * @param Mage_Sales_Model_Order $order
     *
     * @return array
     */
    protected function getCreditMemoQtys(Mage_Sales_Model_Order $order)
    {
        ...
    }

    /**
     * @param Mage_Sales_Model_Order $order
     *
     * @return float|null
     */
    protected function getCreditMemoShippingAmount(Mage_Sales_Model_Order $order)
    {
        ...
    }

    /**
     * @param Mage_Sales_Model_Order $order
     *
     * @return float|null
     */
    protected function getCreditMemoAdjustmentPositive(Mage_Sales_Model_Order $order)
    {
        ...
    }

    /**
     * @param Mage_Sales_Model_Order $order
     *
     * @return float|null
     */
    protected function getCreditMemoAdjustmentNegative(Mage_Sales_Model_Order $order)
    {
        ...
    }

    /**
     * @param Mage_Sales_Model_Order $order
     */
    protected function prepareOrder(Mage_Sales_Model_Order $order)
    {
        ...
    }

    /**
     * @param Mage_Sales_Model_Order $order
     */
    protected function followUpOrder(Mage_Sales_Model_Order $order)
    {
        ...
    }

    /**
     * @param Mage_Sales_Model_Order $order
     *
     * @return bool
     */
    protected function canSendCreditMemo(Mage_Sales_Model_Order $order)
    {
        ...
    }
}

License

Tofex Sales Jobs is licensed under the MIT License - see the LICENSE file for details.