We have a custom extension that worked on mageplaza custom pdf invoice extension on magento 2.2.7.
The mageplaza module needed to be updated, so we did. Now the updated module is not compatible with the other extension that fixes the layout of magento2 attributes on the invoice...
So the two extensions that should work together are:
- FrikandelX Invoice
- Mageplaza/Pdfinvoice
Unfortunatly when we compiled magento code it throws this error:
Errors during compilation:
FrikandelX\Invoice\Block\Invoice\Items
Incompatible argument type: Required type:
\Mageplaza\PdfInvoice\Helper\Data. Actual type: array; File:
/xx/Xx/mage227-dev/app/code/FrikandelX/Invoice/Block/Invoice/Items.php
Total Errors Count: 1
This is the FrikandelX file:
/public_html/app/code/FrikandelX/Invoice/Block/Invoice/Items.php
use Magento\Framework\View\Element\Template\Context; use Magento\Tax\Helper\Data;
class Items extends \Mageplaza\PdfInvoice\Block\Invoice\Items{ protected $_productRepository;
public function __construct(
Context $context,
Data $taxHelper,
\Magento\Catalog\Api\ProductRepositoryInterface $productRepository,
array $data = []
)
{
parent::__construct($context, $taxHelper, $data);
$this->_productRepository = $productRepository;
}
public function getProduct($sku)
{
try {
$product = $this->_productRepository->get($sku);
} catch (\Exception $e) {
return false;
}
return $product;
}
private function _getProduct($sku)
{
try {
$product = $this->_productRepository->get($sku);
} catch (\Exception $e) {
var_dump($sku);
exit($e->getMessage());
}
die;
}
public function getDiscount($item, $product, $invoice)
{
if($item->getPrice() == $product->getPrice()){
$discountAmount = $item->getDiscountAmount();
if($discountAmount){
$rowTotalDiscounted = $item->getRowTotal() - $discountAmount;
$rowTotal = $product->getPrice() * $item->getQty();
$item->setRowTotal($rowTotalDiscounted);
$invoice->setSubTotal($invoice->getSubTotal() - $rowTotal + $rowTotalDiscounted);
$invoice->setDiscountAmount(null);
return 100 - round($rowTotalDiscounted / $rowTotal * 100, 0);
}
return '0';
}
return 100 - round($item->getPrice() / $product->getPrice() * 100, 0);
}
}
Any help would be greatly appriciated. I hope I explained it clearly and thank you so much for your help !