I want to create orders pragmatically by getting the data from xml. Reading data from xml part is done. when creating order steps i am getting this error.

Parse error: syntax error, unexpected '$quote' (T_VARIABLE) in

Below is my code lines

namespace Eight25media\MpowerSync\Controller\Adminhtml\mpowersync;

use Magento\Backend\App\Action\Context;

class Testorderimport extends \Magento\Backend\App\Action
......some code here.....
protected $quote;
protected $quoteManagement;
......some code here.....
public function __construct(
    Context $context,
......some code here.....
\Magento\Quote\Model\QuoteFactory $quote,
\Magento\Quote\Model\QuoteManagement $quoteManagement,
......some code here.....
) { 
......some code here.....
$this->quote = $quote;
$this->quoteManagement = $quoteManagement;
......some code here.....

public function execute(){
......some code here.....
$websiteId  = $this->_storeManager->getWebsite()->getWebsiteId();
$customer = $this->customer;
if ($websiteId) {
$customer_id = $customer->getId();
//create customer 

$store = $this->_storeManager->getStore();
$quote = $this->quote->create();

$customer = $this->customerRepository->getById($customer_id);
......some code here.....

I am getting this error $quote->assignCustomer($customer) here in this line.

May be some one faced the same issue you before, any help would be great for me to short it out or else suggest me a tutorial.

I tried Magecamp, mageplaza,webkul tutorials.

  • 5
    have you used the cartManagementInterface and cartRepositoryInterface in order to load quote that define in webkul tutorial? Also please write the complete error in question – Muhammad Hasham Mar 13 '19 at 5:59
  • 1
    Hi @Mujahidh, Can you please remove comma behind this line \Magento\Quote\Model\QuoteManagement $quoteManagement, – Ravi Soni Mar 13 '19 at 6:00
  • @MuhammadHasham no i dint try – Mujahidh Mar 13 '19 at 6:22
  • @Ravi There were some other lines coming after that – Mujahidh Mar 13 '19 at 6:23
  • I thought it was the last line. – Ravi Soni Mar 13 '19 at 6:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.