Seem that you tried to follow the Magento 1 way. In Magento 2, there are no local
, community
code pool.
We need to use Dependency injection to override the class.
app/code/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">
<preference type="Magento\Sales\Model\Order\Pdf\Invoice"for="Magento\Sales\Model\Order\Pdf\Invoice"
for="Vendor\Module\Model\Order\Pdf\Invoice"type="Vendor\Module\Model\Order\Pdf\Invoice"/>
</config>
app/code/Vendor/Module/Model/Order/Pdf/Invoice.php
<?php
namespace Vendor\Module\Model\Order\Pdf;
class Invoice extends \Magento\Sales\Model\Order\Pdf\Invoice
{
//Your custom code lines
}
Recommended way: We can use Plugin to modify the behaviour of methods in Magento 2: http://devdocs.magento.com/guides/v2.1/extension-dev-guide/plugins.html