Hemi Connectors / Magento2 Technical Scope / Magento 2 Connector Integration / Magento2 Export Orders Per Seller

Magento2 Export Orders Per Seller

We have a new challenging requirement for one of our clients and we need to add additional logic to be able to split the orders per Magento seller when exporting. The major change here will be we will need to add Connector ID on order item level as well because one order with two item from two different sellers will need to be exported to two different Magentos. Also we will need to calculate the order totals in different way depends how many products we are exporting. The way we are shipping orders will remain the same depends which Magento first push the shipping update we will ship the whole order. There will be a change in the way we are creating credit memos as well because they need to be pushed to the correct Mangeto store based on the items added for the refund and again the correct amounts need to be pushed.

The setup in Hemi will look like as follows: Each eBay account will have two Magento sellers for example Seller Accessories and Seller Goods.

Seller Accessories and Seller Goods will have two different Magento 2 Connectors and each Magento Seller will export to different Magento2 systems.

Every order item will have Seller ID obtained from the Account based on the internal Hemi script and we need to map the Order Item > Seller with the Magento 2 Seller > Seller and export only order items with the same seller. This way if we have order with Accessories and Goods Sellers we will export the order items in two separate Magento2 systems.

The whole new logic will be controlled by an additional flag added in Magento 2 Seller > Export Orders Per Seller. If we have Export Orders Per Seller Activated we will need to:

  1. Start storing the Magento Order IDs in new field in Order Item > Connector ID and mark them as Order Item > Magento Exported = Yes once we successfully create an order in Magento2. The Orders > Connector ID will contain the first returned ID from Magento2. If we do not have Order Item > Seller ID we wont export the order. If we do not have spited shipping cost = yes we do not export the order. These are required fields before we export the order to Magento2

  2. The order export mapping will need to be changed as follows

Please note everything in red is the new changes in the mapping and we are keeping the logic if we have the US taxes we export them otherwise we use our internal VAT calculations!

Magento Field Hemi Field Comment
entity >base_currency_code orders > order_currency
entity >base_discount_amount
entity >base_grand_total order item > item price * order item > quantity +order item > Item Shipping Cost Calculate the item price * quantity and add the shipping cost.
We need to group the order items per seller.
entity >base_shipping_amount order item > Item Shipping Cost - Order Item > Vat Shipping Cost Value
order item > Item Shipping Cost - Order Item > Item Shipping Cost Sales Tax
entity >base_shipping_incl_tax order item > Item Shipping Cost
entity >base_shipping_tax_amount orders > Item Shipping Cost Sales Tax.
order Item > Vat Shipping Cost Value We need to sum the Vat Shipping Cost Value from all order items
entity >base_shipping_discount_amount
entity >base_subtotal order item > item price * order item > quantity - Order Item > Vat Item Price
order item > item price * order item > quantity - Order Item > Item Tax Price For all products with the same seller
entity >base_subtotal_incl_tax order item > item price * order item > quantity
entity >base_total_due Hardcoded as “0“
entity >base_total_paid order item > item price * order item > quantity +order item > Item Shipping Cost
entity >base_to_global_rate Hardcoded as “1“
entity >base_to_order_rate Hardcoded as “1“
entity >discount_tax_compensation_amount Hardcoded as “0“
entity >base_discount_tax_compensation_amount Hardcoded as “0“
entity >shipping_discount_tax_compensation_amount Hardcoded as “0“
entity >customer_is_guest Hardcoded as “1“
entity >customer_email orders > buyer_mail
entity >customer_firstname orders > shipping_buyer_name
entity >customer_group_id Hardcoded as “0“
entity >customer_lastname orders > orders > shipping_buyer_name Send only the last name
entity >customer_note_notify Hardcoded as “0“
entity >discount_amount Hardcoded as “0“
entity > customer_note label_request > url
entity >email_sent Hardcoded as “1“
entity >ext_order_id orders > marketplace_order_id
entity >global_currency_code orders > order_currency
entity >grand_total order item > item price * order item > quantity +order item > Item Shipping Cost
entity >order_currency_code orders > order_currency
entity >shipping_amount order item > Item Shipping Cost - Order Item > Vat Shipping Cost Value
order item > Item Shipping Cost - Order Item > Item Shipping Cost Sales Tax
entity >shipping_tax_amount orders > Item Shipping Cost Sales Tax.
order Item > Vat Shipping Cost Value We need to sum the Vat Shipping Cost Value from all order items
entity >shipping_description orders > shipping_service
entity >shipping_discount_amount
entity >shipping_incl_tax order item > Item Shipping Cost
entity >state Hardcoded as “processing“
entity >status Hardcoded as “in_fulfillment“
entity >store_currency_code orders > order_currency
entity >store_to_base_rate Hardcoded as “0“
entity >store_to_order_rate Hardcoded as “0“
entity >store_id magento2_seller > Store Code
entity >subtotal order item > item price * order item > quantity - Order Item > Vat Item Price
order item > item price * order item > quantity - Order Item > Item Tax Price
entity >subtotal_incl_tax order item > item price * order item > quantity
entity >total_due Hardcoded as “0“
entity >total_paid order item > item price * order item > quantity +order item > Item Shipping Cost
entity >total_item_count order_item > id We need to COUNT the seller order item ids
entity >total_qty_ordered order_item > item_quantity We need to sum the seller item quantity
entity >tax_amount (order item > item_quantity * Order Item > Vat Item Price) + Order Item > Vat Shipping Cost Value
(order item > item_quantity * Order Item > Item Tax Price) +Order Item > Item Shipping Cost Sales The Sum of all order items with that seller.
entity > base_tax_amount (order item > item_quantity * Order Item > Vat Item Price) + Order Item > Vat Shipping Cost Value
(order item > item_quantity * Order Item > Item Tax Price) +Order Item > Item Shipping Cost Sales The Sum of all order items with that seller.
entity >weight order_item > item_weight Sum of the seller order item weight, If not populated in Hemi use the default weight
entity >items>base_original_price item_account > RRP
entity >items>base_price order_item > item_trans_price Without VAT
entity >items>base_price_incl_tax order_item > item_trans_price
entity >items>base_row_total order_item > item_trans_price * order_item >item_quantity Without VAT
entity >items>base_row_total_incl_tax order_item > item_trans_price * order_item >item_quantity
entity >items>name order_item > item_title
entity >items>original_price item_account > RRP
entity >items>price order_item > item_trans_price Without VAT
entity >items>price_incl_tax order_item > item_trans_price
entity >items>product_type Hardcoded as “configurable“
entity >items>qty_ordered order_item >item_quantity
entity >items>row_total order_item > item_trans_price Without VAT and the sum of the Qty * Price
entity >items>row_total_incl_tax order_item > item_trans_price Sum of the Qty * Price
entity >items>sku order_item > item_sku
entity >items>store_id magento2_seller > Store Code
entity >items>base_tax_amount Order Item > Vat Item Price / Item tax price If we have populated the item tax price we pick it otherwise we use the Vat Item Price
entity >items>tax_amount Order Item > Vat Item Price / Item tax price If we have populated the item tax price we pick it otherwise we use the Vat Item Price
entity >items>weight order_item > item_weight If not populated in Hemi use the default weight
entity >billing_address>address_type Hardcoded as “billing“
entity >billing_address>city orders > billing_cityname
entity >billing_address>company orders >billing_company_name
entity >billing_address>country_id orders >billing_country_code
entity >billing_address>email orders >buyer_mail
entity >billing_address>firstname orders >billing_name
entity >billing_address>lastname orders >billing_name Only the last name of the string
entity >billing_address>postcode orders >billing_postal_code
entity >billing_address>region orders >billing_state_province
entity >billing_address>street orders > billing_street1 / billing_street2 Can have Multiple Strings
entity >billing_address>telephone orders >billing_phone
entity >payment>method Hardcoded as “purchaseorder“
entity >payment>po_number orders > id
entity >status_histories>comment Hardcoded as ““
entity >status_histories>status orders > tool_status Additional Mapping provided
entity >extension_attributes>shipping_assignments>shipping>address>address_type Hardcoded as "shipping"
entity >extension_attributes>shipping_assignments>shipping>address>city orders > shipping_city
entity >extension_attributes>shipping_assignments>shipping>address>company orders >shipping_company_name
entity >extension_attributes>shipping_assignments>shipping>address>country_id orders >shipping_country_code
entity >extension_attributes>shipping_assignments>shipping>address>email orders >buyer_mail
entity >extension_attributes>shipping_assignments>shipping>address>firstname orders >shipping_buyer_name
entity >extension_attributes>shipping_assignments>shipping>address>lastname orders >shipping_buyer_name Get only the last string
entity >extension_attributes>shipping_assignments>shipping>address>postcode orders >shipping_postal_code
entity >extension_attributes>shipping_assignments>shipping>address>region orders >shipping_state_province
entity >extension_attributes>shipping_assignments>shipping>address>street orders >shipping_street1/shipping_street2
entity >extension_attributes>shipping_assignments>shipping>address>telephone orders >shipping_phone
entity >extension_attributes>shipping_assignments>shipping>method orders >shipping_service
entity >extension_attributes>shipping_assignments>shipping>total>base_shipping_amount orders >shipping_service_cost Without VAT
entity >extension_attributes>shipping_assignments>shipping>total>base_shipping_incl_tax orders >shipping_service_cost
entity >extension_attributes>shipping_assignments>shipping>total>shipping_amount orders >shipping_service_cost Without VAT
entity >extension_attributes>shipping_assignments>shipping>total>shipping_incl_tax orders >shipping_service_cost
entity >extension_attributes>shipping_assignments>items>base_original_price item_account > RRP
entity >extension_attributes>shipping_assignments>items>base_price order_item > item_trans_price Without VAT
entity >extension_attributes>shipping_assignments>items>base_price_incl_tax order_item > item_trans_price
entity >extension_attributes>shipping_assignments>items>base_row_total order item > item price * order item > quantity Without VAT
entity >extension_attributes>shipping_assignments>items>base_row_total_incl_tax order item > item price * order item > quantity + Order Item > Vat Item Price
order item > item price * order item > quantity + Order Item > Item Tax Price
entity >extension_attributes>shipping_assignments>items>name order_item > item_title
entity >extension_attributes>shipping_assignments>items>original_price item_account > RRP
entity >extension_attributes>shipping_assignments>items>price order_item > item_strans_price Without VAT
entity >extension_attributes>shipping_assignments>items>price_incl_tax order_item > item_strans_price
entity >extension_attributes>shipping_assignments>items>product_type Hardcoded as "configurable"
entity >extension_attributes>shipping_assignments>items>qty_ordered order_item > item_quantity
entity >extension_attributes>shipping_assignments>items>row_total order_item > item_strans_price Without VAT and Sum Price * Qty
entity >extension_attributes>shipping_assignments>items>row_total_incl_tax order_item > item_strans_price Sum Price * Qty
entity >extension_attributes>shipping_assignments>items>sku order_item > item_sku
entity >extension_attributes>shipping_assignments>items>store_id magento2_seller > Store Code
entity >extension_attributes>shipping_assignments>items>weight order_item > item_weigth
entity >extension_attributes>extension_attributes Can be excluded from the payload
entity >extension_attributes>applied_taxes Can be excluded from the payload
entity >extension_attributes>item_applied_taxes Can be excluded from the payload
entity >extension_attributes>converting_from_quote Hardcoded as "false"

Basically we group the order items per seller and sum the amounts.

  1. When we are getting the shipping updates from Magento2 will need to map the orders, based on the new field connector id in Order Item and despite for which order item we will receive the shipping update we ship the whole order. Basically we get the shipments from both Magentos and whichever ship the order first we ship the whole order.

  2. If we have a refund downloaded from the marketplace and need to be pushed to Magento2 , based on the Order Refund Row > Order Item ID we will need to map it with the Order Item > SKU and create the credit memo in the correct Magento2 based on the Order Item > Seller. Credit memos are offline refund on Magento which are not processed in any way just sit for refence.

Is this article helpful?
0 0 0