Create shipment programmatically and facing errorGenerate invoice automatically when I create shipment?How to create a shipment pdf programmatically?Unable to create shipment programmaticallyShipment create not working programmaticallyMagento 2 : extensionpool, read handlers and save handlersWarning: Invalid argument supplied for foreach() when viewing shipmentmagento 2 cannot do shipment for the order 404Get Shipment Id while creating Shipment in Magento 1.9Magento 2 - How to create item wise shipment And add tracking number programmaticallyShipment view page 404 error
Was any UN Security Council vote triple-vetoed?
Arrow those variables!
A newer friend of my brother's gave him a load of baseball cards that are supposedly extremely valuable. Is this a scam?
Is it legal for company to use my work email to pretend I still work there?
Replacing matching entries in one column of a file by another column from a different file
Rock identification in KY
Is it possible to do 50 km distance without any previous training?
How much RAM could one put in a typical 80386 setup?
Modeling an IP Address
What does "Puller Prush Person" mean?
Convert two switches to a dual stack, and add outlet - possible here?
What's the point of deactivating Num Lock on login screens?
Approximately how much travel time was saved by the opening of the Suez Canal in 1869?
Can a Cauchy sequence converge for one metric while not converging for another?
How do I deal with an unproductive colleague in a small company?
Perform and show arithmetic with LuaLaTeX
Intersection point of 2 lines defined by 2 points each
A case of the sniffles
Why can't we play rap on piano?
Client team has low performances and low technical skills: we always fix their work and now they stop collaborate with us. How to solve?
dbcc cleantable batch size explanation
How old can references or sources in a thesis be?
How much of data wrangling is a data scientist's job?
Why doesn't H₄O²⁺ exist?
Create shipment programmatically and facing error
Generate invoice automatically when I create shipment?How to create a shipment pdf programmatically?Unable to create shipment programmaticallyShipment create not working programmaticallyMagento 2 : extensionpool, read handlers and save handlersWarning: Invalid argument supplied for foreach() when viewing shipmentmagento 2 cannot do shipment for the order 404Get Shipment Id while creating Shipment in Magento 1.9Magento 2 - How to create item wise shipment And add tracking number programmaticallyShipment view page 404 error
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I am trying to create shipment programmatically. Following a tutorial, but facing error on save shipment.
Here is the code that I am using:
$orderId = 100002156;
$order = $this->_orderRepository->get($orderId);
if (!$order->canShip())
echo "Can't Ship";
die;
$orderShipment = $this->_convertOrder->toShipment($order);
foreach ($order->getAllItems() AS $orderItem) $orderItem->getIsVirtual())
continue;
$qty = $orderItem->getQtyToShip();
$shipmentItem = $convertOrder->itemToShipmentItem($orderItem)->setQty($qty);
$orderShipment->addItem($shipmentItem);
$orderShipment->register();
$orderShipment->getOrder()->setIsInProcess(true);
$this->save();
$this->getOrder()->save();
Can anyone tell what is the issue?
magento2 shipment
add a comment |
I am trying to create shipment programmatically. Following a tutorial, but facing error on save shipment.
Here is the code that I am using:
$orderId = 100002156;
$order = $this->_orderRepository->get($orderId);
if (!$order->canShip())
echo "Can't Ship";
die;
$orderShipment = $this->_convertOrder->toShipment($order);
foreach ($order->getAllItems() AS $orderItem) $orderItem->getIsVirtual())
continue;
$qty = $orderItem->getQtyToShip();
$shipmentItem = $convertOrder->itemToShipmentItem($orderItem)->setQty($qty);
$orderShipment->addItem($shipmentItem);
$orderShipment->register();
$orderShipment->getOrder()->setIsInProcess(true);
$this->save();
$this->getOrder()->save();
Can anyone tell what is the issue?
magento2 shipment
what is the context of your code, in what class do you use this code? And what is the error on which save ($this->save()
whatever object$this
is or$this->getOrder()->save();
?
– HelgeB
yesterday
I am using it in controller
– Asim Ali
yesterday
add a comment |
I am trying to create shipment programmatically. Following a tutorial, but facing error on save shipment.
Here is the code that I am using:
$orderId = 100002156;
$order = $this->_orderRepository->get($orderId);
if (!$order->canShip())
echo "Can't Ship";
die;
$orderShipment = $this->_convertOrder->toShipment($order);
foreach ($order->getAllItems() AS $orderItem) $orderItem->getIsVirtual())
continue;
$qty = $orderItem->getQtyToShip();
$shipmentItem = $convertOrder->itemToShipmentItem($orderItem)->setQty($qty);
$orderShipment->addItem($shipmentItem);
$orderShipment->register();
$orderShipment->getOrder()->setIsInProcess(true);
$this->save();
$this->getOrder()->save();
Can anyone tell what is the issue?
magento2 shipment
I am trying to create shipment programmatically. Following a tutorial, but facing error on save shipment.
Here is the code that I am using:
$orderId = 100002156;
$order = $this->_orderRepository->get($orderId);
if (!$order->canShip())
echo "Can't Ship";
die;
$orderShipment = $this->_convertOrder->toShipment($order);
foreach ($order->getAllItems() AS $orderItem) $orderItem->getIsVirtual())
continue;
$qty = $orderItem->getQtyToShip();
$shipmentItem = $convertOrder->itemToShipmentItem($orderItem)->setQty($qty);
$orderShipment->addItem($shipmentItem);
$orderShipment->register();
$orderShipment->getOrder()->setIsInProcess(true);
$this->save();
$this->getOrder()->save();
Can anyone tell what is the issue?
magento2 shipment
magento2 shipment
asked yesterday
Asim AliAsim Ali
8211
8211
what is the context of your code, in what class do you use this code? And what is the error on which save ($this->save()
whatever object$this
is or$this->getOrder()->save();
?
– HelgeB
yesterday
I am using it in controller
– Asim Ali
yesterday
add a comment |
what is the context of your code, in what class do you use this code? And what is the error on which save ($this->save()
whatever object$this
is or$this->getOrder()->save();
?
– HelgeB
yesterday
I am using it in controller
– Asim Ali
yesterday
what is the context of your code, in what class do you use this code? And what is the error on which save (
$this->save()
whatever object $this
is or $this->getOrder()->save();
?– HelgeB
yesterday
what is the context of your code, in what class do you use this code? And what is the error on which save (
$this->save()
whatever object $this
is or $this->getOrder()->save();
?– HelgeB
yesterday
I am using it in controller
– Asim Ali
yesterday
I am using it in controller
– Asim Ali
yesterday
add a comment |
1 Answer
1
active
oldest
votes
Try This :-
$objectManager = $bootstrap->getObjectManager();
$state = $objectManager->get('MagentoFrameworkAppState');
$state->setAreaCode('frontend');
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$orderInterface = $objectManager->get('MagentoSalesApiDataOrderInterface');
$incrementId = "000000165"; //Increment Id
$order = $objectManager->create('MagentoSalesModelOrder')
->loadByAttribute('increment_id', $incrementId);
if ($order->canShip())
$convertOrder = $objectManager->create('MagentoSalesModelConvertOrder');
$shipment = $convertOrder->toShipment($order);
foreach ($order->getAllItems() AS $orderItem) $orderItem->getIsVirtual())
continue;
$qtyShipped = $orderItem->getQtyToShip();
$shipmentItem = $convertOrder->itemToShipmentItem($orderItem)->setQty($qtyShipped);
$shipment->addItem($shipmentItem);
$shipment->register();
$shipment->getOrder()->setIsInProcess(true);
try
// Save created shipment and order
$shipment->save();
$shipment->getOrder()->save();
catch (Exception $e)
echo "Shipment Not Created". $e->getMessage(); exit;
echo "Shipment Succesfully Generated for order: #".$incrementId;
else
echo "Shipment Not Created Becuase It's already created or something went wrong";
Thanks Ronak Rathod, will try this
– Asim Ali
yesterday
Working Or Not ??? Most Welcome
– Ronak Rathod
yesterday
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%2f268820%2fcreate-shipment-programmatically-and-facing-error%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Try This :-
$objectManager = $bootstrap->getObjectManager();
$state = $objectManager->get('MagentoFrameworkAppState');
$state->setAreaCode('frontend');
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$orderInterface = $objectManager->get('MagentoSalesApiDataOrderInterface');
$incrementId = "000000165"; //Increment Id
$order = $objectManager->create('MagentoSalesModelOrder')
->loadByAttribute('increment_id', $incrementId);
if ($order->canShip())
$convertOrder = $objectManager->create('MagentoSalesModelConvertOrder');
$shipment = $convertOrder->toShipment($order);
foreach ($order->getAllItems() AS $orderItem) $orderItem->getIsVirtual())
continue;
$qtyShipped = $orderItem->getQtyToShip();
$shipmentItem = $convertOrder->itemToShipmentItem($orderItem)->setQty($qtyShipped);
$shipment->addItem($shipmentItem);
$shipment->register();
$shipment->getOrder()->setIsInProcess(true);
try
// Save created shipment and order
$shipment->save();
$shipment->getOrder()->save();
catch (Exception $e)
echo "Shipment Not Created". $e->getMessage(); exit;
echo "Shipment Succesfully Generated for order: #".$incrementId;
else
echo "Shipment Not Created Becuase It's already created or something went wrong";
Thanks Ronak Rathod, will try this
– Asim Ali
yesterday
Working Or Not ??? Most Welcome
– Ronak Rathod
yesterday
add a comment |
Try This :-
$objectManager = $bootstrap->getObjectManager();
$state = $objectManager->get('MagentoFrameworkAppState');
$state->setAreaCode('frontend');
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$orderInterface = $objectManager->get('MagentoSalesApiDataOrderInterface');
$incrementId = "000000165"; //Increment Id
$order = $objectManager->create('MagentoSalesModelOrder')
->loadByAttribute('increment_id', $incrementId);
if ($order->canShip())
$convertOrder = $objectManager->create('MagentoSalesModelConvertOrder');
$shipment = $convertOrder->toShipment($order);
foreach ($order->getAllItems() AS $orderItem) $orderItem->getIsVirtual())
continue;
$qtyShipped = $orderItem->getQtyToShip();
$shipmentItem = $convertOrder->itemToShipmentItem($orderItem)->setQty($qtyShipped);
$shipment->addItem($shipmentItem);
$shipment->register();
$shipment->getOrder()->setIsInProcess(true);
try
// Save created shipment and order
$shipment->save();
$shipment->getOrder()->save();
catch (Exception $e)
echo "Shipment Not Created". $e->getMessage(); exit;
echo "Shipment Succesfully Generated for order: #".$incrementId;
else
echo "Shipment Not Created Becuase It's already created or something went wrong";
Thanks Ronak Rathod, will try this
– Asim Ali
yesterday
Working Or Not ??? Most Welcome
– Ronak Rathod
yesterday
add a comment |
Try This :-
$objectManager = $bootstrap->getObjectManager();
$state = $objectManager->get('MagentoFrameworkAppState');
$state->setAreaCode('frontend');
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$orderInterface = $objectManager->get('MagentoSalesApiDataOrderInterface');
$incrementId = "000000165"; //Increment Id
$order = $objectManager->create('MagentoSalesModelOrder')
->loadByAttribute('increment_id', $incrementId);
if ($order->canShip())
$convertOrder = $objectManager->create('MagentoSalesModelConvertOrder');
$shipment = $convertOrder->toShipment($order);
foreach ($order->getAllItems() AS $orderItem) $orderItem->getIsVirtual())
continue;
$qtyShipped = $orderItem->getQtyToShip();
$shipmentItem = $convertOrder->itemToShipmentItem($orderItem)->setQty($qtyShipped);
$shipment->addItem($shipmentItem);
$shipment->register();
$shipment->getOrder()->setIsInProcess(true);
try
// Save created shipment and order
$shipment->save();
$shipment->getOrder()->save();
catch (Exception $e)
echo "Shipment Not Created". $e->getMessage(); exit;
echo "Shipment Succesfully Generated for order: #".$incrementId;
else
echo "Shipment Not Created Becuase It's already created or something went wrong";
Try This :-
$objectManager = $bootstrap->getObjectManager();
$state = $objectManager->get('MagentoFrameworkAppState');
$state->setAreaCode('frontend');
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$orderInterface = $objectManager->get('MagentoSalesApiDataOrderInterface');
$incrementId = "000000165"; //Increment Id
$order = $objectManager->create('MagentoSalesModelOrder')
->loadByAttribute('increment_id', $incrementId);
if ($order->canShip())
$convertOrder = $objectManager->create('MagentoSalesModelConvertOrder');
$shipment = $convertOrder->toShipment($order);
foreach ($order->getAllItems() AS $orderItem) $orderItem->getIsVirtual())
continue;
$qtyShipped = $orderItem->getQtyToShip();
$shipmentItem = $convertOrder->itemToShipmentItem($orderItem)->setQty($qtyShipped);
$shipment->addItem($shipmentItem);
$shipment->register();
$shipment->getOrder()->setIsInProcess(true);
try
// Save created shipment and order
$shipment->save();
$shipment->getOrder()->save();
catch (Exception $e)
echo "Shipment Not Created". $e->getMessage(); exit;
echo "Shipment Succesfully Generated for order: #".$incrementId;
else
echo "Shipment Not Created Becuase It's already created or something went wrong";
answered yesterday
Ronak RathodRonak Rathod
1,097213
1,097213
Thanks Ronak Rathod, will try this
– Asim Ali
yesterday
Working Or Not ??? Most Welcome
– Ronak Rathod
yesterday
add a comment |
Thanks Ronak Rathod, will try this
– Asim Ali
yesterday
Working Or Not ??? Most Welcome
– Ronak Rathod
yesterday
Thanks Ronak Rathod, will try this
– Asim Ali
yesterday
Thanks Ronak Rathod, will try this
– Asim Ali
yesterday
Working Or Not ??? Most Welcome
– Ronak Rathod
yesterday
Working Or Not ??? Most Welcome
– Ronak Rathod
yesterday
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%2f268820%2fcreate-shipment-programmatically-and-facing-error%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
what is the context of your code, in what class do you use this code? And what is the error on which save (
$this->save()
whatever object$this
is or$this->getOrder()->save();
?– HelgeB
yesterday
I am using it in controller
– Asim Ali
yesterday