<?php
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$resource = $objectManager->get('Magento\Framework\App\ResourceConnection');
$connection = $resource->getConnection();
$tableName = $resource->getTableName('table_name');
$attribute_information = "Select * FROM " . $tableName; //check for the custom attribute condition". WHERE id = " . $manufacture . ";";
// fetchOne it return the one value
$result = $connection->fetchOne($attribute_information);
// For Example : I just saving custom data in custom column in order table'
$orderdata = $observer->getEvent()->getOrder();
$_objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$orderIncrementId = $orderdata->getIncrementId();
$order = $_objectManager->create('Magento\Sales\Model\Order')->loadByIncrementId($orderIncrementId);
$increment_id = $order->getIncrementId();
$codFee = $order->getMspCodAmount() + $order->getMspCodTaxAmount();
$resource = $_objectManager->get('Magento\Framework\App\ResourceConnection');
$connection = $resource->getConnection();
$tableName = $resource->getTableName('sales_order');
$sql = "Update " . $tableName . " Set cash_on_delivery_fee = '$codFee' where increment_id ='$increment_id'";
$connection->query($sql);
Comments
Post a Comment