Magento 2 create Order programatically and set a custom date to ithow to set custom field in orderHow to create quote and order programmatically in Magento2Programatically Create Order in Magento 2.1Magento 2 How to create new order attribute programaticallyDate validation on my custom form on frontend magento 2Magento 2: Get Order Information Outside Magento Issue for DateCustom Date Fields in CMS Block in magento 2How to create Magento Order programatically in Amazon M2eproCreate Order programatically, not working via cronMagento 1.9 set custom field/attribute when order is set to complete
Why would future John risk sending back a T-800 to save his younger self?
How to retract an idea already pitched to an employer?
Inconsistent behavior of compiler optimization of unused string
Using a found spellbook as a Sorcerer-Wizard multiclass
BGP multihome issue
Interview not reimboursed if offer is made but not accepted
Taxi Services at Didcot
Using "subway" as name for London Underground?
Should I compare a std::string to "string" or "string"s?
Were Alexander the Great and Hephaestion lovers?
Where does "0 packages can be updated." come from?
Movie about a boy who was born old and grew young
Facebook Marketing API asset access suddenly denied
How did students remember what to practise between lessons without any sheet music?
"You've got another thing coming" - translation into French
What could have caused a rear derailleur to end up in the back wheel suddenly?
How is water heavier than petrol, even though its molecular weight is less than petrol?
How to tell your grandparent to not come to fetch you with their car?
Compiling c files on ubuntu and using the executable on Windows
Words that signal future content
Chemmacros scheme translation
Can anyone identify this tank?
Are there downsides to using std::string as a buffer?
Is it a problem if <h4>, <h5> and <h6> are smaller than regular text?
Magento 2 create Order programatically and set a custom date to it
how to set custom field in orderHow to create quote and order programmatically in Magento2Programatically Create Order in Magento 2.1Magento 2 How to create new order attribute programaticallyDate validation on my custom form on frontend magento 2Magento 2: Get Order Information Outside Magento Issue for DateCustom Date Fields in CMS Block in magento 2How to create Magento Order programatically in Amazon M2eproCreate Order programatically, not working via cronMagento 1.9 set custom field/attribute when order is set to complete
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I have a order to create an order in magento 2. But the order it create is with the date when i run the script. I don't want to save the current date for the order. I want to set a certain date to the that order.
magento2 magento-2.1 sales-order
add a comment |
I have a order to create an order in magento 2. But the order it create is with the date when i run the script. I don't want to save the current date for the order. I want to set a certain date to the that order.
magento2 magento-2.1 sales-order
add a comment |
I have a order to create an order in magento 2. But the order it create is with the date when i run the script. I don't want to save the current date for the order. I want to set a certain date to the that order.
magento2 magento-2.1 sales-order
I have a order to create an order in magento 2. But the order it create is with the date when i run the script. I don't want to save the current date for the order. I want to set a certain date to the that order.
magento2 magento-2.1 sales-order
magento2 magento-2.1 sales-order
edited May 30 at 5:57
Avesh Naik
asked May 29 at 11:16
Avesh NaikAvesh Naik
485114
485114
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
A tricky wat, you set your desired time to created_at field
Magento 2 has a method setCreatedAt() and using this method can set Order created time.
So add below code after the end of your order creation code and run update()
of this code.
public function __construct(
MagentoSalesApiOrderRepositoryInterface $orderRepository,
MagentoSalesModelResourceModelOrder $orderResourceModel
)
$this->orderResourceModel = $orderResourceModel;
$this->orderRepository = $orderRepository;
public function update()
$order = $this->orderRepository->get(1); // 1 is order id
$order->setCreatedAt($createdAt); // set time
$this->orderRepository->save($order);
No it didn't worked.
– Avesh Naik
May 31 at 7:22
add a comment |
Finally i found the solution.
My question was not fully complete. Sorry about that. I wanted the order date to be on certain date. The order is not yet created. I am creating the order using my custom code. To create an order i need to create Quote. So if i change the quote create and update date then i reflects to order date too.
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f276573%2fmagento-2-create-order-programatically-and-set-a-custom-date-to-it%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
A tricky wat, you set your desired time to created_at field
Magento 2 has a method setCreatedAt() and using this method can set Order created time.
So add below code after the end of your order creation code and run update()
of this code.
public function __construct(
MagentoSalesApiOrderRepositoryInterface $orderRepository,
MagentoSalesModelResourceModelOrder $orderResourceModel
)
$this->orderResourceModel = $orderResourceModel;
$this->orderRepository = $orderRepository;
public function update()
$order = $this->orderRepository->get(1); // 1 is order id
$order->setCreatedAt($createdAt); // set time
$this->orderRepository->save($order);
No it didn't worked.
– Avesh Naik
May 31 at 7:22
add a comment |
A tricky wat, you set your desired time to created_at field
Magento 2 has a method setCreatedAt() and using this method can set Order created time.
So add below code after the end of your order creation code and run update()
of this code.
public function __construct(
MagentoSalesApiOrderRepositoryInterface $orderRepository,
MagentoSalesModelResourceModelOrder $orderResourceModel
)
$this->orderResourceModel = $orderResourceModel;
$this->orderRepository = $orderRepository;
public function update()
$order = $this->orderRepository->get(1); // 1 is order id
$order->setCreatedAt($createdAt); // set time
$this->orderRepository->save($order);
No it didn't worked.
– Avesh Naik
May 31 at 7:22
add a comment |
A tricky wat, you set your desired time to created_at field
Magento 2 has a method setCreatedAt() and using this method can set Order created time.
So add below code after the end of your order creation code and run update()
of this code.
public function __construct(
MagentoSalesApiOrderRepositoryInterface $orderRepository,
MagentoSalesModelResourceModelOrder $orderResourceModel
)
$this->orderResourceModel = $orderResourceModel;
$this->orderRepository = $orderRepository;
public function update()
$order = $this->orderRepository->get(1); // 1 is order id
$order->setCreatedAt($createdAt); // set time
$this->orderRepository->save($order);
A tricky wat, you set your desired time to created_at field
Magento 2 has a method setCreatedAt() and using this method can set Order created time.
So add below code after the end of your order creation code and run update()
of this code.
public function __construct(
MagentoSalesApiOrderRepositoryInterface $orderRepository,
MagentoSalesModelResourceModelOrder $orderResourceModel
)
$this->orderResourceModel = $orderResourceModel;
$this->orderRepository = $orderRepository;
public function update()
$order = $this->orderRepository->get(1); // 1 is order id
$order->setCreatedAt($createdAt); // set time
$this->orderRepository->save($order);
edited May 29 at 12:23
answered May 29 at 11:43
Amit Bera♦Amit Bera
60.8k1682181
60.8k1682181
No it didn't worked.
– Avesh Naik
May 31 at 7:22
add a comment |
No it didn't worked.
– Avesh Naik
May 31 at 7:22
No it didn't worked.
– Avesh Naik
May 31 at 7:22
No it didn't worked.
– Avesh Naik
May 31 at 7:22
add a comment |
Finally i found the solution.
My question was not fully complete. Sorry about that. I wanted the order date to be on certain date. The order is not yet created. I am creating the order using my custom code. To create an order i need to create Quote. So if i change the quote create and update date then i reflects to order date too.
add a comment |
Finally i found the solution.
My question was not fully complete. Sorry about that. I wanted the order date to be on certain date. The order is not yet created. I am creating the order using my custom code. To create an order i need to create Quote. So if i change the quote create and update date then i reflects to order date too.
add a comment |
Finally i found the solution.
My question was not fully complete. Sorry about that. I wanted the order date to be on certain date. The order is not yet created. I am creating the order using my custom code. To create an order i need to create Quote. So if i change the quote create and update date then i reflects to order date too.
Finally i found the solution.
My question was not fully complete. Sorry about that. I wanted the order date to be on certain date. The order is not yet created. I am creating the order using my custom code. To create an order i need to create Quote. So if i change the quote create and update date then i reflects to order date too.
answered May 31 at 7:25
Avesh NaikAvesh Naik
485114
485114
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f276573%2fmagento-2-create-order-programatically-and-set-a-custom-date-to-it%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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