0

I am getting guest customer Collection with:

\Magento\Sales\Model\ResourceModel\Order\CollectionFactory $orderCollectionFactory

as:

public function getGuestOrderCollection()
  {    
   $orderCollecion = $this->_orderCollectionFactory->create()->addFieldToSelect('*');
   $orderCollecion->addAttributeToFilter('customer_is_guest', ['eq'=>1]);
   return $orderCollecion;
  }

Currently I am not getting ID for guest customer by this but it works without guest customer:

$Id = $_order->getId();

I am looking to change guest customer information by this. Can any body help me to now about it. Thanks

1 Answer 1

0

There are no customer id returns for guest. The $Id you got is actually order_id. If you want to change the guest customer info, you can use the following code for an order:

$_order->setCustomerEmail("[email protected]"); //Set "Email"

If you want to modify the addresses, you can use the following code:

$bill_address = $order->getBillingAddress();
$bill_address->setTelephone(12345678);  //Set "Telephone" inside billing address
$ship_address = $order->getShippingAddress();
$ship_address->setTelephone(98765432);  //Set "Telephone" inside shipping address
5
  • yes it is setting the updated email by this way but when I get email addresses of all orders it shows old email address for that order number and not the updated one..
    – Ajwad Syed
    Commented Nov 27, 2018 at 11:35
  • Do you have $_order->save() in the end?
    – PY Yick
    Commented Nov 27, 2018 at 13:48
  • Yes I have $_order->save() in the end
    – Ajwad Syed
    Commented Nov 27, 2018 at 14:02
  • That's strange. How about adding save immediately after setCustomerEmail?
    – PY Yick
    Commented Nov 27, 2018 at 15:08
  • It worked this time.
    – Ajwad Syed
    Commented Dec 13, 2018 at 12:29

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.