/   /   /  OroCommerce for developers: Snippets and Overview about Order tables From DB:

Note:

For more extensions and themes visit our store

OroCommerce for developers: Snippets and Overview about Order tables From DB:


Snippets

Get Order Repository:

  1.  
  2. use  Oro\Bundle\OrderBundle\Entity\Order;
  3. $doctrineHelper = $this->container->get('oro_entity.doctrine_helper');
  4. //or
  5. $doctrineHelper = $this->container->get('doctrine');
  6. //get Rep
  7. $orderRepository = $doctrineHelper->getEntityRepositoryForClass(Order::class);
  8. //or
  9. $orderRepository = $this->doctrine->getRepository('OroOrderBundle:Order');
  10.  

Load Order:

  1.  
  2. $id = 2;
  3. $order = $orderRepository->find($id);
  4.  

Get line Items from order:

  1.  
  2. $id = 2;
  3. $lineItems = $order->getLineItems();
  4. foreach ($order->getLineItems() as $lineItem) {
  5.    //code example
  6. }
  7.  

Get Billing Address from order:

  1.  
  2. $billingAddress= $order->getBillingAddress();
  3.  

Load Order With all relation lineItems, shippingAddress, billingAddress, discounts

  1.  
  2. $id = 2;
  3. $fullOrder = $orderRepository->getOrderWithRelations($id);
  4. $shippingAdressObject = $fullOrder->shippingAddress->getPhone();
  5.  

Overview

- We have 5 tables related to Order management
oro_order
oro_order_address
oro_order_discount
oro_order_line_item
oro_order_shipping_tracking

The shipping and billing address of order  is stocked in oro_order_address table and has foreign key on the table  oro_order => shipping_address_id & billing_address_id

All Order Items is stocked on the table oro_order_line_item this last has  foreign key order_id

The relation between order and payment is virtual created by oro via foreign key payment_term_7c4f1e8e_id which is primary key of oro_payment_term

oro_order_shipping_tracking is a table which stock the tracking number and shipping method , and one order can have multi shipping and methods and multi tracking number , the field order_id is the foreign key which related to oro_order

- Order Status
The status related to order stocked on the table oro_enum_order_internal_status :
Archived
Cancelled
Closed
Open
Shipped

- We have 2 tables related to Invoice management
oro_invoice
oro_invoice_line_item

no direct relation between oro_invoice and oro_order


- About Payment
The big players is the table oro_payment_transaction which has all info about payment but the best thing in this table the 2 columns entity_class and entity_identifier which means that transaction might has a relation with other entities not just order . 

The other table is oro_payment_status which has a column payment_status can be full or partial and
2 columns entity_class and entity_identifier .

Comments

Related Posts

make your store more efficient

Solving problems. With open source technology. Professional results. That’s what makes Ibnab your best choice

IBNAB is a company made of a group of professionals whose work is providing secure open source solutions. Our company strives for reaching magnificent results with each experience and provides professional open source solutions that cover every part of the business process.