2

Right now, I'm simply attempting to override the Pager class. Without changing anything within it, I've copied it into my module, and then specified the preference in the di:

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="Magento\Theme\Block\Html\Pager" type="MyVendor\Core\Block\Html\Pager"/>
</config>

Problem is, after doing so, I run into a Type Error when creating an Item class:

1 exception(s):
Exception #0 (Magento\Framework\Exception\RuntimeException): Type Error occurred when creating object: Magento\Catalog\Model\Layer\Filter\Item

Exception #0 (Magento\Framework\Exception\RuntimeException): Type Error occurred when creating object: Magento\Catalog\Model\Layer\Filter\Item
<pre>#1 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create('Magento\Catalog\...', array()) called at [vendor/magento/framework/ObjectManager/ObjectManager.php:56]
#2 Magento\Framework\ObjectManager\ObjectManager->create('\Magento\Catalog...', array()) called at [generated/code/Magento/Catalog/Model/Layer/Filter/ItemFactory.php:43]
#3 Magento\Catalog\Model\Layer\Filter\ItemFactory->create() called at [vendor/magento/module-catalog/Model/Layer/Filter/AbstractFilter.php:236]
#4 Magento\Catalog\Model\Layer\Filter\AbstractFilter->_createItem('Cut-Off Wheels', 1045, 15) called at [vendor/magento/module-catalog/Model/Layer/Filter/AbstractFilter.php:205]
#5 Magento\Catalog\Model\Layer\Filter\AbstractFilter->_initItems() called at [vendor/magento/module-catalog/Model/Layer/Filter/AbstractFilter.php:159]
#6 Magento\Catalog\Model\Layer\Filter\AbstractFilter->getItems() called at [vendor/magento/module-catalog/Model/Layer/Filter/AbstractFilter.php:148]
#7 Magento\Catalog\Model\Layer\Filter\AbstractFilter->getItemsCount() called at [vendor/magento/module-catalog/Model/Layer/Category/AvailabilityFlag.php:33]
#8 Magento\Catalog\Model\Layer\Category\AvailabilityFlag->canShowOptions(array(&Magento\CatalogSearch\Model\Layer\Filter\Category#0000000062560a0700000000508c807a#, &Magento\CatalogSearch\Model\Layer\Filter\Attribute#0000000062560e2500000000508c807a#, &Magento\CatalogSearch\Model\Layer\Filter\Attribute#0000000062561cb500000000508c807a#, &Magento\CatalogSearch\Model\Layer\Filter\Attribute#0000000062561d4000000000508c807a#, &Magento\CatalogSearch\Model\Layer\Filter\Attribute#000000006256144100000000508c807a#, &Magento\CatalogSearch\Model\Layer\Filter\Attribute#000000006256145000000000508c807a#, &Magento\CatalogSearch\Model\Layer\Filter\Attribute#000000006256145e00000000508c807a#, &Magento\CatalogSearch\Model\Layer\Filter\Price#0000000062561cc900000000508c807a#, &Magento\CatalogSearch\Model\Layer\Filter\Attribute#0000000062561c3d00000000508c807a#, &Magento\CatalogSearch\Model\Layer\Filter\Attribute#0000000062561c9700000000508c807a#, &Magento\CatalogSearch\Model\Layer\Filter\Attribute#000000006256065f00000000508c807a#, &Magento\CatalogSearch\Model\Layer\Filter\Attribute#0000000062561c3200000000508c807a#, &Magento\CatalogSearch\Model\Layer\Filter\Attribute#0000000062561c3f00000000508c807a#, &Magento\CatalogSearch\Model\Layer\Filter\Attribute#0000000062561c9b00000000508c807a#, &Magento\CatalogSearch\Model\Layer\Filter\Attribute#0000000062561c1e00000000508c807a#, &Magento\CatalogSearch\Model\Layer\Filter\Attribute#0000000062561c2800000000508c807a#, &Magento\CatalogSearch\Model\Layer\Filter\Attribute#000000006256073200000000508c807a#, &Magento\CatalogSearch\Model\Layer\Filter\Attribute#000000006256073100000000508c807a#, &Magento\CatalogSearch\Model\Layer\Filter\Attribute#000000006256069900000000508c807a#, &Magento\CatalogSearch\Model\Layer\Filter\Attribute#000000006256069d00000000508c807a#, &Magento\CatalogSearch\Model\Layer\Filter\Attribute#000000006256070400000000508c807a#, &Magento\CatalogSearch\Model\Layer\Filter\Attribute#000000006256070f00000000508c807a#, &Magento\CatalogSearch\Model\Layer\Filter\Attribute#0000000062560b0800000000508c807a#, &Magento\CatalogSearch\Model\Layer\Filter\Attribute#0000000062560b1100000000508c807a#, &Magento\CatalogSearch\Model\Layer\Filter\Attribute#0000000062560b1400000000508c807a#, &Magento\CatalogSearch\Model\Layer\Filter\Attribute#0000000062560b0d00000000508c807a#, &Magento\CatalogSearch\Model\Layer\Filter\Attribute#0000000062560b7b00000000508c807a#, &Magento\CatalogSearch\Model\Layer\Filter\Attribute#0000000062560b0600000000508c807a#)) called at [vendor/magento/module-catalog/Model/Layer/Category/AvailabilityFlag.php:23]
#9 Magento\Catalog\Model\Layer\Category\AvailabilityFlag->isEnabled(&Magento\Catalog\Model\Layer\Category\Interceptor#000000006256039000000000508c807a#, array(&Magento\CatalogSearch\Model\Layer\Filter\Category#0000000062560a0700000000508c807a#, &Magento\CatalogSearch\Model\Layer\Filter\Attribute#0000000062560e2500000000508c807a#, &Magento\CatalogSearch\Model\Layer\Filter\Attribute#0000000062561cb500000000508c807a#, &Magento\CatalogSearch\Model\Layer\Filter\Attribute#0000000062561d4000000000508c807a#, &Magento\CatalogSearch\Model\Layer\Filter\Attribute#000000006256144100000000508c807a#, &Magento\CatalogSearch\Model\Layer\Filter\Attribute#000000006256145000000000508c807a#, &Magento\CatalogSearch\Model\Layer\Filter\Attribute#000000006256145e00000000508c807a#, &Magento\CatalogSearch\Model\Layer\Filter\Price#0000000062561cc900000000508c807a#, &Magento\CatalogSearch\Model\Layer\Filter\Attribute#0000000062561c3d00000000508c807a#, &Magento\CatalogSearch\Model\Layer\Filter\Attribute#0000000062561c9700000000508c807a#, &Magento\CatalogSearch\Model\Layer\Filter\Attribute#000000006256065f00000000508c807a#, &Magento\CatalogSearch\Model\Layer\Filter\Attribute#0000000062561c3200000000508c807a#, &Magento\CatalogSearch\Model\Layer\Filter\Attribute#0000000062561c3f00000000508c807a#, &Magento\CatalogSearch\Model\Layer\Filter\Attribute#0000000062561c9b00000000508c807a#, &Magento\CatalogSearch\Model\Layer\Filter\Attribute#0000000062561c1e00000000508c807a#, &Magento\CatalogSearch\Model\Layer\Filter\Attribute#0000000062561c2800000000508c807a#, &Magento\CatalogSearch\Model\Layer\Filter\Attribute#000000006256073200000000508c807a#, &Magento\CatalogSearch\Model\Layer\Filter\Attribute#000000006256073100000000508c807a#, &Magento\CatalogSearch\Model\Layer\Filter\Attribute#000000006256069900000000508c807a#, &Magento\CatalogSearch\Model\Layer\Filter\Attribute#000000006256069d00000000508c807a#, &Magento\CatalogSearch\Model\Layer\Filter\Attribute#000000006256070400000000508c807a#, &Magento\CatalogSearch\Model\Layer\Filter\Attribute#000000006256070f00000000508c807a#, &Magento\CatalogSearch\Model\Layer\Filter\Attribute#0000000062560b0800000000508c807a#, &Magento\CatalogSearch\Model\Layer\Filter\Attribute#0000000062560b1100000000508c807a#, &Magento\CatalogSearch\Model\Layer\Filter\Attribute#0000000062560b1400000000508c807a#, &Magento\CatalogSearch\Model\Layer\Filter\Attribute#0000000062560b0d00000000508c807a#, &Magento\CatalogSearch\Model\Layer\Filter\Attribute#0000000062560b7b00000000508c807a#, &Magento\CatalogSearch\Model\Layer\Filter\Attribute#0000000062560b0600000000508c807a#)) called at [vendor/magento/module-layered-navigation/Block/Navigation.php:110]
#10 Magento\LayeredNavigation\Block\Navigation->canShowBlock() called at [vendor/magento/module-layered-navigation/view/frontend/templates/layer/view.phtml:18]
#11 include('/vagrant/vendor/...') called at [vendor/magento/framework/View/TemplateEngine/Php.php:59]
#12 Magento\Framework\View\TemplateEngine\Php->render(&Magento\LayeredNavigation\Block\Navigation#00000000625619d000000000508c807a#, '/vagrant/vendor/...', array()) called at [vendor/magento/framework/View/Element/Template.php:271]
#13 Magento\Framework\View\Element\Template->fetchView('/vagrant/vendor/...') called at [vendor/magento/framework/View/Element/Template.php:301]
#14 Magento\Framework\View\Element\Template->_toHtml() called at [vendor/magento/framework/View/Element/AbstractBlock.php:668]
#15 Magento\Framework\View\Element\AbstractBlock->toHtml() called at [vendor/magento/framework/View/Layout.php:557]
#16 Magento\Framework\View\Layout->_renderBlock('catalog.leftnav') called at [vendor/magento/framework/View/Layout.php:533]
#17 Magento\Framework\View\Layout->renderNonCachedElement('catalog.leftnav') called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
#18 Magento\Framework\View\Layout\Interceptor->renderNonCachedElement('catalog.leftnav') called at [vendor/magento/framework/View/Layout.php:488]
#19 Magento\Framework\View\Layout->renderElement('catalog.leftnav', false) called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
#20 Magento\Framework\View\Layout\Interceptor->renderElement('catalog.leftnav', false) called at [vendor/magento/framework/View/Layout.php:585]
#21 Magento\Framework\View\Layout->_renderContainer('sidebar.main', false) called at [vendor/magento/framework/View/Layout.php:535]
#22 Magento\Framework\View\Layout->renderNonCachedElement('sidebar.main') called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
#23 Magento\Framework\View\Layout\Interceptor->renderNonCachedElement('sidebar.main') called at [vendor/magento/framework/View/Layout.php:488]
#24 Magento\Framework\View\Layout->renderElement('sidebar.main', false) called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
#25 Magento\Framework\View\Layout\Interceptor->renderElement('sidebar.main', false) called at [vendor/magento/framework/View/Layout.php:585]
#26 Magento\Framework\View\Layout->_renderContainer('div.sidebar.main', false) called at [vendor/magento/framework/View/Layout.php:535]
#27 Magento\Framework\View\Layout->renderNonCachedElement('div.sidebar.main') called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
#28 Magento\Framework\View\Layout\Interceptor->renderNonCachedElement('div.sidebar.main') called at [vendor/magento/framework/View/Layout.php:488]
#29 Magento\Framework\View\Layout->renderElement('div.sidebar.main', false) called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
#30 Magento\Framework\View\Layout\Interceptor->renderElement('div.sidebar.main', false) called at [vendor/magento/framework/View/Layout.php:585]
#31 Magento\Framework\View\Layout->_renderContainer('columns', false) called at [vendor/magento/framework/View/Layout.php:535]
#32 Magento\Framework\View\Layout->renderNonCachedElement('columns') called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
#33 Magento\Framework\View\Layout\Interceptor->renderNonCachedElement('columns') called at [vendor/magento/framework/View/Layout.php:488]
#34 Magento\Framework\View\Layout->renderElement('columns', false) called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
#35 Magento\Framework\View\Layout\Interceptor->renderElement('columns', false) called at [vendor/magento/framework/View/Layout.php:585]
#36 Magento\Framework\View\Layout->_renderContainer('main.content', false) called at [vendor/magento/framework/View/Layout.php:535]
#37 Magento\Framework\View\Layout->renderNonCachedElement('main.content') called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
#38 Magento\Framework\View\Layout\Interceptor->renderNonCachedElement('main.content') called at [vendor/magento/framework/View/Layout.php:488]
#39 Magento\Framework\View\Layout->renderElement('main.content', false) called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
#40 Magento\Framework\View\Layout\Interceptor->renderElement('main.content', false) called at [vendor/magento/framework/View/Layout.php:585]
#41 Magento\Framework\View\Layout->_renderContainer('page.wrapper', false) called at [vendor/magento/framework/View/Layout.php:535]
#42 Magento\Framework\View\Layout->renderNonCachedElement('page.wrapper') called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
#43 Magento\Framework\View\Layout\Interceptor->renderNonCachedElement('page.wrapper') called at [vendor/magento/framework/View/Layout.php:488]
#44 Magento\Framework\View\Layout->renderElement('page.wrapper', false) called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
#45 Magento\Framework\View\Layout\Interceptor->renderElement('page.wrapper', false) called at [vendor/magento/framework/View/Layout.php:585]
#46 Magento\Framework\View\Layout->_renderContainer('root', false) called at [vendor/magento/framework/View/Layout.php:535]
#47 Magento\Framework\View\Layout->renderNonCachedElement('root') called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:206]
#48 Magento\Framework\View\Layout\Interceptor->renderNonCachedElement('root') called at [vendor/magento/framework/View/Layout.php:488]
#49 Magento\Framework\View\Layout->renderElement('root', true) called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:193]
#50 Magento\Framework\View\Layout\Interceptor->renderElement('root') called at [vendor/magento/framework/View/Layout.php:954]
#51 Magento\Framework\View\Layout->getOutput() called at [vendor/magento/framework/Interception/Interceptor.php:58]
#52 Magento\Framework\View\Layout\Interceptor->___callParent('getOutput', array()) called at [vendor/magento/framework/Interception/Interceptor.php:138]
#53 Magento\Framework\View\Layout\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#54 Magento\Framework\View\Layout\Interceptor->___callPlugins('getOutput', array(), array(array('layout-model-cac...'))) called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:494]
#55 Magento\Framework\View\Layout\Interceptor->getOutput() called at [vendor/magento/framework/View/Result/Page.php:258]
#56 Magento\Framework\View\Result\Page->render(&Magento\Framework\App\Response\Http\Interceptor#0000000062560b7100000000508c807a#) called at [vendor/magento/framework/View/Result/Layout.php:171]
#57 Magento\Framework\View\Result\Layout->renderResult(&Magento\Framework\App\Response\Http\Interceptor#0000000062560b7100000000508c807a#) called at [vendor/magento/framework/Interception/Interceptor.php:58]
#58 Magento\Framework\View\Result\Page\Interceptor->___callParent('renderResult', array(&Magento\Framework\App\Response\Http\Interceptor#0000000062560b7100000000508c807a#)) called at [vendor/magento/framework/Interception/Interceptor.php:138]
#59 Magento\Framework\View\Result\Page\Interceptor->Magento\Framework\Interception\{closure}(&Magento\Framework\App\Response\Http\Interceptor#0000000062560b7100000000508c807a#) called at [vendor/magento/framework/Interception/Interceptor.php:153]
#60 Magento\Framework\View\Result\Page\Interceptor->___callPlugins('renderResult', array(&Magento\Framework\App\Response\Http\Interceptor#0000000062560b7100000000508c807a#), array(array('result-messages', 'result-builtin-c...', 'result-varnish-c...'))) called at [generated/code/Magento/Framework/View/Result/Page/Interceptor.php:130]
#61 Magento\Framework\View\Result\Page\Interceptor->renderResult(&Magento\Framework\App\Response\Http\Interceptor#0000000062560b7100000000508c807a#) called at [vendor/magento/framework/App/Http.php:140]
#62 Magento\Framework\App\Http->launch() called at [generated/code/Magento/Framework/App/Http/Interceptor.php:24]
#63 Magento\Framework\App\Http\Interceptor->launch() called at [vendor/magento/framework/App/Bootstrap.php:258]
#64 Magento\Framework\App\Bootstrap->run(&Magento\Framework\App\Http\Interceptor#0000000062560a9c00000000508c807a#) called at [pub/index.php:40]
</pre>

Any ideas as to what is going on here?

Alright, I think I'm beginning to understand a little. Item is injecting \Magento\Theme\Block\Html\Pager, and throwing an error as my class doesn't match, even though I'm overriding it with the di preference. Any way around this?

1
  • try to run setup upgrade , static content deploy , clear chache and then check Commented Apr 10, 2019 at 21:16

2 Answers 2

0

In order to get past the Type Error, I had to change my Pager to extend the base Pager class as opposed to the base Template class as the original did.

0

In di.xml use,

<preference for="Magento\Theme\Block\Html\Pager" type="MyVendor\Core\Block\Html\Pager"/>

In MyVendor\Core\Block\Html\Pager use,

namespace MyVendor\Core\Block\Html;

Extend the class by using,

class Pager extends \Magento\Theme\Block\Html\Pager
{
public function MyCustomFunction()

{
   return "working";

} 
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.