PHP code example of aashan / module-link-guest-orders

1. Go to this page and download the library: Download aashan/module-link-guest-orders library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

aashan / module-link-guest-orders example snippets


 
...

use Aashan\LinkGuestOrder\Helper\OrderLinkHelper;
use Magento\Sales\Model\ResourceModel\Order\CollectionFactory;
...

public function __constructor(
	...,
	OrderLinkHelper $helper,
	CollectionFactory $factory,
	...
){
	$this->helper = $helper;
	$this->factory = $factory;
};

...
...

public function linkOrderById($orderId){
	$order = $this->factory
				->create()
				->addFieldToFilter(
					'entity_id', 
					$orderId
				)
				->getFirstItem();
	$this->helper->linkOrderToCustomer($order);
}
...