Issue in pragmatically create orders in magento 2












1















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



<?php
namespace Eight25mediaMpowerSyncControllerAdminhtmlmpowersync;

use MagentoBackendAppActionContext;

class Testorderimport extends MagentoBackendAppAction
{
......some code here.....
protected $quote;
protected $quoteManagement;
......some code here.....
public function __construct(
Context $context,
......some code here.....
MagentoQuoteModelQuoteFactory $quote,
MagentoQuoteModelQuoteManagement $quoteManagement,
......some code here.....
) {
parent::__construct($context);
......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->setWebsiteId($websiteId);
}
$customer->loadByEmail($email);
$customer_id = $customer->getId();
if(!$customer->getId()){
//create customer
}

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

$customer = $this->customerRepository->getById($customer_id);
$quote->setCurrency($order_currency_code);
$quote->assignCustomer($customer);
......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.










share|improve this question




















  • 1





    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
    38 mins ago






  • 1





    Hi @Mujahidh, Can you please remove comma behind this line MagentoQuoteModelQuoteManagement $quoteManagement,

    – Ravi
    36 mins ago











  • @MuhammadHasham no i dint try

    – Mujahidh
    15 mins ago













  • @Ravi There were some other lines coming after that

    – Mujahidh
    14 mins ago











  • I thought it was the last line.

    – Ravi
    10 mins ago
















1















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



<?php
namespace Eight25mediaMpowerSyncControllerAdminhtmlmpowersync;

use MagentoBackendAppActionContext;

class Testorderimport extends MagentoBackendAppAction
{
......some code here.....
protected $quote;
protected $quoteManagement;
......some code here.....
public function __construct(
Context $context,
......some code here.....
MagentoQuoteModelQuoteFactory $quote,
MagentoQuoteModelQuoteManagement $quoteManagement,
......some code here.....
) {
parent::__construct($context);
......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->setWebsiteId($websiteId);
}
$customer->loadByEmail($email);
$customer_id = $customer->getId();
if(!$customer->getId()){
//create customer
}

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

$customer = $this->customerRepository->getById($customer_id);
$quote->setCurrency($order_currency_code);
$quote->assignCustomer($customer);
......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.










share|improve this question




















  • 1





    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
    38 mins ago






  • 1





    Hi @Mujahidh, Can you please remove comma behind this line MagentoQuoteModelQuoteManagement $quoteManagement,

    – Ravi
    36 mins ago











  • @MuhammadHasham no i dint try

    – Mujahidh
    15 mins ago













  • @Ravi There were some other lines coming after that

    – Mujahidh
    14 mins ago











  • I thought it was the last line.

    – Ravi
    10 mins ago














1












1








1








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



<?php
namespace Eight25mediaMpowerSyncControllerAdminhtmlmpowersync;

use MagentoBackendAppActionContext;

class Testorderimport extends MagentoBackendAppAction
{
......some code here.....
protected $quote;
protected $quoteManagement;
......some code here.....
public function __construct(
Context $context,
......some code here.....
MagentoQuoteModelQuoteFactory $quote,
MagentoQuoteModelQuoteManagement $quoteManagement,
......some code here.....
) {
parent::__construct($context);
......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->setWebsiteId($websiteId);
}
$customer->loadByEmail($email);
$customer_id = $customer->getId();
if(!$customer->getId()){
//create customer
}

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

$customer = $this->customerRepository->getById($customer_id);
$quote->setCurrency($order_currency_code);
$quote->assignCustomer($customer);
......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.










share|improve this question
















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



<?php
namespace Eight25mediaMpowerSyncControllerAdminhtmlmpowersync;

use MagentoBackendAppActionContext;

class Testorderimport extends MagentoBackendAppAction
{
......some code here.....
protected $quote;
protected $quoteManagement;
......some code here.....
public function __construct(
Context $context,
......some code here.....
MagentoQuoteModelQuoteFactory $quote,
MagentoQuoteModelQuoteManagement $quoteManagement,
......some code here.....
) {
parent::__construct($context);
......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->setWebsiteId($websiteId);
}
$customer->loadByEmail($email);
$customer_id = $customer->getId();
if(!$customer->getId()){
//create customer
}

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

$customer = $this->customerRepository->getById($customer_id);
$quote->setCurrency($order_currency_code);
$quote->assignCustomer($customer);
......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.







orders custom magento2.2.2 programmatically






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 9 mins ago







Mujahidh

















asked 47 mins ago









MujahidhMujahidh

1,40012036




1,40012036








  • 1





    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
    38 mins ago






  • 1





    Hi @Mujahidh, Can you please remove comma behind this line MagentoQuoteModelQuoteManagement $quoteManagement,

    – Ravi
    36 mins ago











  • @MuhammadHasham no i dint try

    – Mujahidh
    15 mins ago













  • @Ravi There were some other lines coming after that

    – Mujahidh
    14 mins ago











  • I thought it was the last line.

    – Ravi
    10 mins ago














  • 1





    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
    38 mins ago






  • 1





    Hi @Mujahidh, Can you please remove comma behind this line MagentoQuoteModelQuoteManagement $quoteManagement,

    – Ravi
    36 mins ago











  • @MuhammadHasham no i dint try

    – Mujahidh
    15 mins ago













  • @Ravi There were some other lines coming after that

    – Mujahidh
    14 mins ago











  • I thought it was the last line.

    – Ravi
    10 mins ago








1




1





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
38 mins ago





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
38 mins ago




1




1





Hi @Mujahidh, Can you please remove comma behind this line MagentoQuoteModelQuoteManagement $quoteManagement,

– Ravi
36 mins ago





Hi @Mujahidh, Can you please remove comma behind this line MagentoQuoteModelQuoteManagement $quoteManagement,

– Ravi
36 mins ago













@MuhammadHasham no i dint try

– Mujahidh
15 mins ago







@MuhammadHasham no i dint try

– Mujahidh
15 mins ago















@Ravi There were some other lines coming after that

– Mujahidh
14 mins ago





@Ravi There were some other lines coming after that

– Mujahidh
14 mins ago













I thought it was the last line.

– Ravi
10 mins ago





I thought it was the last line.

– Ravi
10 mins ago










0






active

oldest

votes











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "479"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f265605%2fissue-in-pragmatically-create-orders-in-magento-2%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Magento Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f265605%2fissue-in-pragmatically-create-orders-in-magento-2%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

What other Star Trek series did the main TNG cast show up in?

Berlina muro

Berlina aerponto