Переопределяющий блок в Magento 2
Я играю в переопределение блоков в magento 2, вызывается конструктор расширенных блоков, но внутренний метод не работает?
Мой код таков
Di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">
<preference for="Magento\Customer\Block\Account\Dashboard\Info" type="Learning\Customers\Block\Info" />
</config>
Info.php
<?php
namespace Learning\Customers\Block;
use Magento\Framework\View\Element\Template;
class Info extends \Magento\Customer\Block\Account\Dashboard\Info
{
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
\Magento\Customer\Helper\Session\CurrentCustomer $currentCustomer,
\Magento\Newsletter\Model\SubscriberFactory $subscriberFactory,
\Magento\Customer\Helper\View $helperView,
array $data = []
) {
$writer = new \Zend\Log\Writer\Stream(BP . '/var/log/Info.log');
$logger = new \Zend\Log\Logger();
$logger->addWriter($writer);
$logger->info($this->getName());
parent::__construct($context,$currentCustomer,$subscriberFactory,$helperView, $data);
}
public function getName()
{
return 'Magento 2';
}
}
Есть какие-нибудь предложения?
Спасибо.
3
Author: Manoj Kumar, 2015-08-04
2 answers
Добавьте приведенный ниже метод в Info.php
protected function _toHtml()
{
$this->setModuleName($this->extractModuleName('Magento\Customer\Block\Account\Dashboard\Info'));
return parent::_toHtml();
}
См. справочную ссылку Как переопределить блок в Magento 2
5
Author: Bojjaiah, 2015-08-05 05:56:25
Блок переопределения выполнен, но проблема в том, что я получаю текущий идентификатор категории с помощью реестра в magento 2, показывая ошибку
Произошла ошибка при обработке вашего запроса.
Должен быть создан объект DOMDocument
Кто-нибудь знает, как я могу получить текущий идентификатор категории в блоке панели инструментов.
0
Author: Pratik, 2015-08-24 07:21:10