I want to know that what is the use qty_invoiced column in the sales_order_item table in Magento 2.
Magento2 – Use of qty_invoiced Column in sales_order_item Table
magento2magento2.3sales-ordersales-order-item
Related Solutions
You need to use below cod in your setup script of your custom module
<?php
namespace Vendor\Modulename\Setup;
use Magento\Sales\Setup\SalesSetupFactory;
use Magento\Eav\Model\Entity\Attribute\SetFactory as AttributeSetFactory;
use Magento\Framework\Setup\InstallDataInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
/**
* InstallData
*
* @codeCoverageIgnore
*/
class InstallData implements InstallDataInterface
{
/**
* SalesSetupFactory
*
* @var SalesSetupFactory
*/
protected $salesSetupFactory;
/**
* Constructor
* @param SalesSetupFactory $salesSetupFactory
*/
public function __construct(
SalesSetupFactory $salesSetupFactory
) {
$this->salesSetupFactory = $salesSetupFactory;
}
/**
* Install
*
* @param ModuleDataSetupInterface $setup
* @param ModuleContextInterface $context
*/
public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
/** @var \Magento\Sales\Setup\SalesSetup $salesInstaller */
$salesInstaller = $this->salesSetupFactory->create(['resourceName' => 'sales_setup', 'setup' => $setup]);
$salesInstaller->addAttribute('order_item', 'test', ['type' => \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, 'length'=> 10, 'visible' => false,'nullable' => true,]);
}
}
After a several hours finally I have found the solution. Here is the step :
create layout
view/adminhtml/layout/sales_order_view.xml
like this :<referenceContainer name="left"> <block class="Magento\Sales\Block\Adminhtml\Order\View\Tabs" name="sales_order_tabs"> <block class="Magento\Sales\Block\Adminhtml\Order\View\Tab\Info" name="order_tab_info" template="order/view/tab/info.phtml"> <block class="Magento\Sales\Block\Adminhtml\Order\View\Messages" name="order_messages"/> <block class="Magento\Sales\Block\Adminhtml\Order\View\Info" name="order_info" template="order/view/info.phtml"/> <block class="Magento\Sales\Block\Adminhtml\Order\View\Items" name="order_items" template="order/view/items.phtml"> <arguments> <argument name="columns" xsi:type="array"> <item name="product" xsi:type="string" translate="true">Product</item> <item name="status" xsi:type="string" translate="true">Item Status</item> <item name="price-original" xsi:type="string" translate="true">Original Price</item> <item name="price" xsi:type="string" translate="true">Price</item> <item name="ordered-qty" xsi:type="string" translate="true">Qty</item> <item name="subtotal" xsi:type="string" translate="true">Subtotal</item> <item name="tax-amount" xsi:type="string" translate="true">Tax Amount</item> <item name="tax-percent" xsi:type="string" translate="true">Tax Percent</item> <item name="discont" xsi:type="string" translate="true">Discount Amount</item> <item name="total" xsi:type="string" translate="true">Row Total</item> <item name="expected-delivery-time-column" xsi:type="string" translate="true">Expected Delivery Time</item> </argument> </arguments> <block class="Magento\Sales\Block\Adminhtml\Order\View\Items\Renderer\DefaultRenderer" as="default" template="order/view/items/renderer/default.phtml"> <arguments> <argument name="columns" xsi:type="array"> <item name="product" xsi:type="string" translate="false">col-product</item> <item name="status" xsi:type="string" translate="false">col-status</item> <item name="price-original" xsi:type="string" translate="false">col-price-original</item> <item name="price" xsi:type="string" translate="false">col-price</item> <item name="qty" xsi:type="string" translate="false">col-ordered-qty</item> <item name="subtotal" xsi:type="string" translate="false">col-subtotal</item> <item name="tax-amount" xsi:type="string" translate="false">col-tax-amount</item> <item name="tax-percent" xsi:type="string" translate="false">col-tax-percent</item> <item name="discont" xsi:type="string" translate="false">col-discont</item> <item name="total" xsi:type="string" translate="false">col-total</item> <item name="expected-delivery-time" xsi:type="string" translate="true">col-expected-delivery-time</item> </argument> </arguments> </block> <block class="Magento\Sales\Block\Adminhtml\Items\Column\Qty" name="column_qty" template="items/column/qty.phtml" group="column"/> <block class="Magento\Sales\Block\Adminhtml\Items\Column\Name" name="column_name" template="items/column/name.phtml" group="column"/> <block class="Magento\Framework\View\Element\Text\ListText" name="order_item_extra_info"/> </block> <container name="payment_additional_info" htmlTag="div" htmlClass="order-payment-additional" /> <block class="Magento\Sales\Block\Adminhtml\Order\Payment" name="order_payment"/> <block class="Magento\Sales\Block\Adminhtml\Order\View\History" name="order_history" template="order/view/history.phtml"/> <block class="Magento\Backend\Block\Template" name="gift_options" template="Magento_Sales::order/giftoptions.phtml"> <block class="Magento\Sales\Block\Adminhtml\Order\View\Giftmessage" name="order_giftmessage" template="order/view/giftmessage.phtml"/> </block> <block class="Magento\Sales\Block\Adminhtml\Order\Totals" name="order_totals" template="order/totals.phtml"> <block class="Magento\Sales\Block\Adminhtml\Order\Totals\Tax" name="tax" template="order/totals/tax.phtml"/> </block> </block> <action method="addTab"> <argument name="name" xsi:type="string">order_info</argument> <argument name="block" xsi:type="string">order_tab_info</argument> </action> <block class="Magento\Sales\Block\Adminhtml\Order\View\Tab\Invoices" name="sales_order_invoice.grid.container"/> <action method="addTab"> <argument name="name" xsi:type="string">order_invoices</argument> <argument name="block" xsi:type="string">sales_order_invoice.grid.container</argument> </action> <block class="Magento\Sales\Block\Adminhtml\Order\View\Tab\Creditmemos" name="sales_order_creditmemo.grid.container"/> <action method="addTab"> <argument name="name" xsi:type="string">order_creditmemos</argument> <argument name="block" xsi:type="string">sales_order_creditmemo.grid.container</argument> </action> <block class="Magento\Sales\Block\Adminhtml\Order\View\Tab\Shipments" name="sales_order_shipment.grid.container"/> <action method="addTab"> <argument name="name" xsi:type="string">order_shipments</argument> <argument name="block" xsi:type="string">sales_order_shipment.grid.container</argument> </action> <action method="addTab"> <argument name="name" xsi:type="string">order_history</argument> <argument name="block" xsi:type="string">Magento\Sales\Block\Adminhtml\Order\View\Tab\History</argument> </action> <block class="Magento\Sales\Block\Adminhtml\Order\View\Tab\Transactions" name="sales_transactions.grid.container"/> <action method="addTab"> <argument name="name" xsi:type="string">order_transactions</argument> <argument name="block" xsi:type="string">sales_transactions.grid.container</argument> </action> </block>
create plugin to override the method for showing the expected delivery date :
use\Magento\Sales\Block\Adminhtml\Order\View\Items\Renderer\DefaultRenderer
class DefaultRendererPlugin
{
public function aroundGetColumnHtml(DefaultRenderer $defaultRenderer, \Closure $proceed,\Magento\Framework\DataObject $item, $column, $field=null)
{
if ($column == 'expected-delivery-time'){
$html = $item->getExpectedDeliveryTime();
$result = $html;
}else{
if ($field){
$result = $proceed($item,$column,$field);
}else{
$result = $proceed($item,$column);
}
}
return $result;
}
}
etc config :
<type name="Magento\Sales\Block\Adminhtml\Order\View\Items\Renderer\DefaultRenderer"> <plugin name="fabelio-order-view-information" type="Fabelio\Sales\Plugin\DefaultRendererPlugin" sortOrder="1" /> </type>
that's it.
Best Answer
Magento has a feature to invoice a qty as per defined by admin.
e.g customer placed an order with 10 qty but for some reason customer want 5 qty only or instore only 5 available now admin want to procced order with 5 qty only and need to generate invoice for 5 products.so, admin will add 5 qty on invoice creation time instead of 10.
So,In
sales_order_item
tableqty_invoiced
filed will store data for that order.hope you get it now