New answers tagged

0

I also faced same issue. After adding sequence in module.xml <sequence> <module name="Magento_Sales" /> </sequence> I upgrade the Magento. php bin/magento setup:upgrade And issue is resolved.


0

I got the string as below. I have used searchCriteria[pageSize] and searchCriteria[currentPage] to fetch first n order and also can fetch page wise order. $pageSize = 100; // magento will create order table with 100 orders in a page $currentPage = 1; // first page $ch = curl_init("https://yourhost.com/index.php/rest/V1/orders?searchCriteria[filter_groups][0]...


1

For Get Order Collection using REST API with status processing, You can pass below request url to fetch order data from Magento. https://yourhost.com/index.php/rest/V1/orders/?searchCriteria[filterGroups][0][filters][0][field]=status&searchCriteria[filterGroups][0][filters][0][value]=processing&searchCriteria[filterGroups][0][filters][0][...


1

Below Code Worked for me. If you check sales_invoice_item table here order_item_id column contains your Order items id. Vendor\Module\Model\Order\Pdf\Items\Invoice\DefaultInvoice.php <?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace Vendor\Module\Model\Order\Pdf\...


0

Add di.xml with <preference for="Magento\Sales\Model\AdminOrder\Create" type="Vendor\Module\Rewrite\Magento\Sales\Model\AdminOrder\Create"/> Create.php <?php namespace Vendor\Module\Rewrite\Magento\Sales\Model\AdminOrder; class Create extends \Magento\Sales\Model\AdminOrder\Create { /** * Prepare customer data for order creation. ...


0

First of all, you need to disable that extension which causing an issue. Second thing for updating total for a placed order, you need to edit orders from the backend and save that order. So it will update cancel the current order and create a new one with same information. I hope this will help you. Please let me know if you have any query.


0

Please check if cron is running or not. Sales order grid updates by cron only.


0

In Magento, if you want to create a credit memo, then you need to use below class: \Magento\Sales\Api\RefundOrderInterface \Magento\Sales\Api\InvoiceRepositoryInterface \Magento\Sales\Api\Data\CreditmemoItemCreationInterfaceFactory Example: <?php namespace {namespace}; class {ClassName} { /** * @var \Magento\Sales\Api\Data\...


1

Add a new column called Stock while creating the order in the admin need to override the class \Magento\Sales\Block\Adminhtml\Order\Create\Search\Grid and add column qty_in_stock Follow below step to create custom module to add custom column. Step 1) magento/app/code/Venodr/SalesordercreategridStock/registration.php <?php \Magento\Framework\...


2

This is a work around use Plugin instead of Observer. Vendor/Module/etc/di.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <type name="Magento\Sales\Api\OrderRepositoryInterface"> <plugin name="...


0

You can use sales order repository interface. class name : Magento\Sales\Api\OrderRepositoryInterface Usage: Create OrderRepositoryInterface object then load order by id $order = $this->orderRepository->get($orderId); Then set value for attributes $order->setSentToSage(1); And save using orderRepository $this->orderRepository->save($...


2

Try This :- /**Magento/Sales/Model/Order $salesOrder**/ $orderId = 12345; $statusCode = \Magento\Sales\Model\Order::STATE_PROCESSING; $order = $this->salesOrder->load($orderId); $order->setState($order->getState())->setStatus($statusCode); $order->save();


0

Try to implement this check use \Magento\Sales\Api\OrderRepositoryInterface; public function realTest(){ try{ $orderId = 256076; // obtain the order with the order ID $order = $this->_orderRepository->get($orderId); if(!empty($order->getData()){ $...


3

Give a try to below code. With Increment Id $incrementId = 000256076; $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $order = $objectManager->create('\Magento\Sales\Model\Order')->loadByIncrementId($incrementId); $orderState = \Magento\Sales\Model\Order::STATE_PROCESSING; $order->setState($orderState)->setStatus(\...


0

Your code seems to good but Once try to use following code use \Magento\Sales\Api\OrderRepositoryInterface; public function realTest(){ try{ $orderId = 1271; // obtain the order with the order ID $order = $this->_orderRepository->get($orderId); $orderState = \Magento\Sales\Model\Order::...


0

This may help if you don't want to edit the _construct function: private static function getIncrementIDfromOrderID($orderID) { $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); // Instance of object manager $resource = $objectManager->get('Magento\Framework\App\ResourceConnection'); $connection = $resource->...


0

Please try this code of snippet, It will help you <?php namespace Vendor\Module\Controller\Index; use Magento\Framework\App\Action\Action; use Magento\Framework\App\Action\Context; use Magento\Framework\App\ResponseInterface; use Magento\Sales\Model\Order; class Index extends Action { /** * @var \Magento\Framework\Controller\Result\JsonFactory *...


0

Change like this use Magento\Sales\Model\Order; public function __construct( Context $context, \Magento\Sales\Model\Order $orderRepository, \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory ) { parent::__construct($context); $this->resultJsonFactory = $resultJsonFactory; $this->...


0

use Magento\Sales\Model\Order; $orderId = 1; $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $order = $objectManager->create('\Magento\Sales\Model\Order') ->load($orderId); $orderState = Order::STATE_PROCESSING; $order->setState($orderState)->setStatus(Order::STATE_PROCESSING); $order->save(); Please check with this code....


0

Try with below code : protected $orderFactory; public function __construct( \Magento\Sales\Model\Order $orderFactory ) { $this->orderFactory = $orderFactory; } public function execute() { $orderId = 2; $order = $this->orderFactory->load($orderId); $order->setSentToSage(1); $order->save(); }


1

I know this isn't the answer to your problem but when I want to update just 1 attribute I m usually do this: public function updateOrderWithCustomAttributes($orderId,$sentToSage){ $connection = $this->getConnection('core_write'); $sql = "UPDATE `sales_order` SET sent_to_sage = ? WHERE entity_id = ? "; $connection->query($sql, ...


Top 50 recent answers are included