How to get Guest telephone number from Order in Sales_Order table - magento2

I want to fetch Guest telephone number from their order, as I checked from the Database I found the telephone number is saved in sales_order_address not in sales_order. How do I get this data? Thanks in advance

You can retrieve it from order object.
Load your order (using object manager for simplicity, generally you should use dependency injection instead)
$id = "your_order_id";
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$order = $objectManager->create('Magento\Sales\Model\Order')->load($id);
Now you can get the address phone data from the shipping address like this:
$order->getShippingAddress()->getTelephone();

Related

Fetch Email with Mailkit order by Date - need faster way

I need to fetch emails in batches from a mail box which has been through several migrations.
There was an email provider before, then the mail box was migrated to gmail and then to O365.
When I try to use UID, the emails are not fetched in reverse date order.
like this: IMailFolderObject.Fetch(startingUID, EndUID, MessageSummaryItemsObject);
To get emails in reverse date order through Mailkit, I tried to following.
var list = IMailFolderObject.Fetch(0, -1, MessageSummaryItems.Envelope | MessageSummaryItems.UniqueId).ToList();
list.Sort(new OrderBy[] { OrderBy.Date });
The emails are fetched but it takes a real long time to complete the job. Since the mailbox is really large.
I do not want to retrieve all the emails and sort them in my program.
Is there a way to get top 50 emails (sorted by date descending since I can not guarantee the UID order is not matching the order of date descending)
and the rest in batches of 50 in subsequent calls ?
Thanks for help in advance.
This is my first question so please let me know should there be more information.

How should I design MongoDB User Schema for Ecommerce website?

I have designed the User Schema, but I am a bit confused about the User Shipping Address. The user might have many shipping addresses that he wants to save in his profile.
So I am a bit confused whether I should create a separate Address schema and refer the User inside or save the Array of the Address object directly in the User Schema. But, one problem I have noticed; If I save the address in the Address Array under User's Schema, I will not have an object ID for the Address to be identified that which address I want to get. In this situation, I will have to face the problem to update the address.
If someone can tell me how should I go, It will be helpful for me.
You don't need an object ID to do that task.
The solution is that you can just manually assign an id to each address
by just putting both id and address in a json document and then pushing it in the array of addresses.
it will look something like this after in json format
address : [
{
id:1,
address:"address 1"
},
{
id:2,
address:"address 2"
}
]

Split multiple times in Tableau for Join Condition (Datasource or Worksheet)

I have two EXCEL files and trying to use the customer id from one file to match the customer id's that are included as a part of 2nd file which includes a 300 character. The Customer id in the second file is embedded as a part of the 300 characters.
I need to find-out how I can take the customer ids from the first file (customer file) to join them with the second file that includes the customer transactions.
I can use the Datasource Join options and establish one condition such as below,
Customer ID = SPLIT([Field Number],"_",1) but since this condition is not enough and I need multiple SPLITS to get the customer ID based on other conditions using SPLIT, it is not working within the DataSource Tab-> Join Options.
HOW CAN I DO MULTIPLE SPLITS like
Customer ID = SPLIT([Field Number],"",1) OR Customer ID =
SPLIT([Field Number],"GET",6) OR Customer ID = SPLIT([Field
Number],"TEACH",1)
If I need to do this within the Worksheet, using the calculated field, please let me know how I can use the Calcuated Field option but include all the conditions..
Thanks in advance for your time
Customer File:
Picture of the firest file includings the Customer IDs
Transction file:
enter image description here

grabbing parent records in sugarcrm

what I have done? and what I need?
I have created two module 1.invoice 2. payment there is one to many relationship between invoice and payment
it means one invoice have many payment.
for calculating payment I have used a logic hook in payment module.
now I want invoice_id in payment module to retrive data.
for that I use
$invoice = new invoi_invoice();
$invi = $invoice->get_linked_beans('invoi_invoice_t_hotel_payment_1','invoi_invoice');
var_dump($invi);
it return
array(0){
}
and also I used
$invoice = new invoi_invoice();
$id=$invoice->retrieve($bean->invoi_invoice_t_hotel_payment_1invoi_invoice_ida);
but this also does not give me id of invoice.
i have read lots of blog and tutorial all are grabing parent record same like me.
but I don1t get id till now.
any help please..
I got the solution
for simply getting the parent id use
var_dump($_REQUEST);
then you got parent id like this:-
$parent_id=$_REQUEST["return_id"];

how I convert into string?

I select field in database using sql command
partner_obj = self.pool.get('res.partner'). browse (cr, uid, ids, *args)
partner_name = partner_obj.ids
customer = (partner_name)
cr.execute("select b.city from res_partner a, res_partner_address b where b.partner_id = a.id AND a.id = %s",(customer))
ads = cr.fetchone()
city = ads and ads[0] or None
but, I just know we must convert into string. I already try to make like this (the code above), but still doesn't work.
I made like this, because you want to know SO is in a message in which the city
may you help me, please
thank you
I don't think you need to run raw SQL, you should be able to use the browse records to get the information you want. I wasn't sure exactly what you wanted from your question, but I'll assume that you are passing in a list of partner ids, and you want back a list of all the city names that they have addresses in. I have not tested this code, it's just a suggestion.
def find_cities(self, cr, uid, partner_ids, context=None):
cities = set()
partner_obj = self.pool.get('res.partner')
for partner in partner_obj.browse(cr, uid, partner_ids, context):
for address in partner.address:
if address.city:
cities.add(address.city)
return list(cities)
First point in OpenERP city is not relation field so when you will trigger sql to fetch the city you will get the name but if you have any customization which stores the city code then you need one more SQL injection to fine out the matching city from city code.
If like if you have city as relation fields with res_partner_address so in that case city field will store only id of the relation record table so when you use sql injection what you will get is id of the city which is linked to your address.
Let me know if I am missing something, Thank You.