Earlier I posted the solution to remove SKU from product page in Magento 2.
And we know that SKUs are something that the customers need not handle. The customers want to enjoy the shopping and leave handling the technical aspects on the developers!
However, SKUs are important in Magento 2 for unique identification of the products and hence it has a place in the product page, invoice and invoice pdf!
But we know that customers can live without knowing the SKU of the products they purchased
Hence, we’ll remove SKU column from Magento 2 invoice pdf! And that too programmatically so as to quickly finish this task!
Method to remove SKU column from Magento 2 Invoice PDF:
Visit How to Override a Method of Abstract File of Magento 2 Invoice PDF
Remove the below lines from this solution’s override class MagentoSalesModelOrderPdfInvoice
$lines[0][] = ['text' => __('SKU'), 'feed' => 290, 'align' => 'right'];
and also remove following code from MagentoSalesModelOrderPdfItemsInvoiceDefaultInvoice
$lines[0][] = [ // phpcs:ignore Magento2.Functions.DiscouragedFunction 'text' => $this->string->split(html_entity_decode($this->getSku($item)), 17), 'feed' => 290, 'align' => 'right', ];
For downloadable product, go to MagentoDownloadableModelSalesOrderPdfItemsInvoice and comment or remove the below code:
// draw SKU $lines[0][] = [ 'text' => $this->string->split($this->getSku($item), 17), 'feed' => 290, 'align' => 'right', ];
For bundled product, go to MagentoBundleModelSalesOrderPdfItemsInvoice.php and comment or remove the below code:
// draw SKUs if (!$childItem->getOrderItem()->getParentItem()) { $text = []; foreach ($this->string->split($item->getSku(), 17) as $part) { $text[] = $part; } $line[] = ['text' => $text, 'feed' => 255]; }
Adjust the blank space in the PDF by pixels arrangement.
However, if you do not want to make any changes in the default file, you can override it by installing this extension.
That’s it.
Making customers’ life easier is our job and the post helps for the same!
I’d be grateful if you take time out to share the solution with fellow developers via social media.
Thanks.