0

How do get all customer shipping address?

Magento 2.3.5-p1 version

for the customer table, we can use - customer_entity table name

for the customer address table, we can use - customer_address_entity table name

On customer_entity we can see there is a column of default_billing and default_shipping but that column has a specific address id for this I am unable to find out all customer shipping address only.

Note: Need to just check from the database, not from code.

2 Answers 2

0

I believe the customer_address_entity table may be what you are looking for. It has all the address fields such as street, city, country, etc...

4
  • i just want to get only shipping address for all customers Commented Jun 24, 2021 at 15:19
  • Were you able to check the table I mentioned? In there exists all the shipping addresses. You can join using the default_shipping_address field in the customer_entity table in order to filter out billing addresses
    – joeybab3
    Commented Jun 24, 2021 at 15:24
  • shipping address exist and what is here default_shipping_address? Commented Jun 24, 2021 at 15:58
  • Apologies, the field name in customer_entity is actually just default_shipping which is a customer_address_entity.
    – joeybab3
    Commented Jun 24, 2021 at 16:02
0

This will return the default shipping address for all customers

    SELECT 
        c.entity_id,
        c.email,
        e.*
    FROM 
        customer_entity c 
    INNER JOIN
        customer_address_entity e 
    ON 
        c.default_shipping = e.entity_id;

This will return the addresses that were used at least once on a customer order.

SELECT 
    c.entity_id,
    c.email,
    sa.*
FROM 
    customer_entity c 
INNER JOIN
    sales_order s
ON
    c.entity_id = s.customer_id
INNER JOIN
    sales_order_address sa
ON
    s.entity_id = sa.parent_id AND
    s.shipping_address_id = sa.entity_id;

Let me know if you need any further help !

2
  • ok i am checking ant let you know soon Commented Jun 28, 2021 at 12:03
  • Let me know if you need any additional help :) Don't forget to upvote / mark as answer if this solved your issue !
    – Joao71
    Commented Jun 28, 2021 at 15:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.