1
我要重写抽象类的保护功能magento2Magento 2如何在抽象类中重写protected funtion?
这里是我的代码
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 for="Magento\Sales\Model\Order\Pdf\AbstractPdf" type="Custom\Sales\Model\Order\Pdf\AbstractPdf" />
</config>
AbstractPdf.php(自定义/销售/型号/订购/ PDF/AbstractPdf .php)
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
// @codingStandardsIgnoreFile
namespace Custom\Sales\Model\Order\Pdf;
// use Magento\Eav\Model\Entity\Attribute as EntityAttribute;
// use Magento\Eav\Model\Entity\Attribute\AbstractAttribute;
// use Magento\Framework\DB\Select;
// use Magento\Framework\Model\AbstractModel;
// use Magento\Framework\App\Filesystem\DirectoryList;
// use Magento\Framework\DataObject;
/**
* Sales Order PDF abstract model
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class AbstractPdf extends \Magento\Sales\Model\Order\Pdf\AbstractPdf
{
/**
* Insert logo to pdf page
*
* @param \Zend_Pdf_Page &$page
* @param null $store
* @return void
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
protected function insertLogo(&$page, $store = null)
{
echo "override";die;
}
}
我已经覆盖了上面提到的文件的核心模型,但我无法得到解决方案。
请帮我解决这个问题。
非常感谢你@Sejal shah,它被成功地压制了。 – Rana
嗨全部, 我们如何可以覆盖mangento 2供应商\ magento \模块销售\型号\订单\电子邮件\ Sender.php 这个模型我想覆盖prepareTemplate()方法。 –
@Pramod Kharade请提出一个新问题。 –