Snippets
Get Order Repository:
use Oro\Bundle\OrderBundle\Entity\Order; $doctrineHelper = $this->container->get('oro_entity.doctrine_helper'); //or $doctrineHelper = $this->container->get('doctrine'); //get Rep $orderRepository = $doctrineHelper->getEntityRepositoryForClass(Order::class); //or $orderRepository = $this->doctrine->getRepository('OroOrderBundle:Order');
Load Order:
$id = 2; $order = $orderRepository->find($id);
Get line Items from order:
$id = 2; $lineItems = $order->getLineItems(); foreach ($order->getLineItems() as $lineItem) { //code example }
Get Billing Address from order:
$billingAddress= $order->getBillingAddress();
Load Order With all relation lineItems, shippingAddress, billingAddress, discounts
$id = 2; $fullOrder = $orderRepository->getOrderWithRelations($id); $shippingAdressObject = $fullOrder->shippingAddress->getPhone();
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