3

I'm facing this error when i try to login as customer, but when i go back or at Home i was logged in but every time i logout & login back, i face this error, also when i was logged in and go to My Account i get this error, don't know why.

Fatal error: Uncaught Error: Call to a member function setUseContainer() on boolean in /var/www/html/vendor/magento/module-wishlist/Block/Customer/Wishlist.php:127 Stack trace: #0 /var/www/html/vendor/magento/framework/View/Element/AbstractBlock.php(283): Magento\Wishlist\Block\Customer\Wishlist->_prepareLayout() #1 /var/www/html/vendor/magento/framework/View/Layout/Generator/Block.php(149): Magento\Framework\View\Element\AbstractBlock->setLayout(Object(Magento\Framework\View\Layout\Interceptor)) #2 /var/www/html/vendor/magento/framework/View/Layout/GeneratorPool.php(81): Magento\Framework\View\Layout\Generator\Block->process(Object(Magento\Framework\View\Layout\Reader\Context), Object(Magento\Framework\View\Layout\Generator\Context)) #3 /var/www/html/vendor/magento/framework/View/Layout.php(343): Magento\Framework\View\Layout\GeneratorPool->process(Object(Magento\Framework\View\Layout\Reader\Context), Object(Magento\Framework\View\Layout\Generator\Context)) #4 /var/www/html/vendor/magento/framework/View/Layout/Builder.ph in /var/www/html/vendor/magento/module-wishlist/Block/Customer/Wishlist.php on line 127

enter image description here

asked Aug 28, 2019 at 12:39
1
  • are you using any custom method where you call setUseContainer() ? Commented Aug 28, 2019 at 12:57

4 Answers 4

7

I think i should add another answer and leave previous answer as it is for knowledge purpose. I realized that i'm missing something. a very simple way to resolve this issue.

i have two overridden files which are causing this error customer_account_index.xml & wishlist_index_index.xml, i just add wishlist_item_pager block to it's right place. Here it is:

app/design/frontend/Magestore/theme/Magento_Customer/layout/customer_account_index.xml

.
.
.
 <block class="Magento\Wishlist\Block\Customer\Wishlist" name="customer.wishlist" template="customer_account_view.phtml" cacheable="false">
 <block class="Magento\Theme\Block\Html\Pager" name="wishlist_item_pager"/>
.
.
.

app/design/frontend/Magestore/theme/Magento_Wishlist/layout/wishlist_index_index.xml

.
.
.
 <block class="Magento\Wishlist\Block\Customer\Wishlist" name="customer.wishlist" template="view.phtml" cacheable="false">
 <block class="Magento\Theme\Block\Html\Pager" name="wishlist_item_pager"/>
.
.
.
answered Aug 29, 2019 at 12:56
1
  • awesome working for me... Commented Oct 4, 2019 at 9:25
3

The code was introduced here: https://github.com/magento/magento2/pull/19305

As a fix for: https://github.com/magento/magento2/issues/19292

So just check if you've overwritten the wishlist_index_index.xmland have a look if the wishlist_item_pager block is present.

Original code at: https://github.com/webkul-ratnesh/magento2/blob/4a149505a71c883a2c93740d3e4fb5c265a2d267/app/code/Magento/Wishlist/view/frontend/layout/wishlist_index_index.xml#L16

answered Aug 29, 2019 at 11:31
1
  • Thanks mate, but i have another file customer_account_index.xml, which cause this error and wishlist_index_index.xml causing theme issue... I posted another answer. Commented Aug 29, 2019 at 12:58
1

Yes i solved my issue, maybe this is not a good way to solve it, but i've no better option, if you find better answer please let me know.

So their is a file in /vendor/magento/module-wishlist/Block/Customer/Wishlist.php, in this file their is a method _prepareLayout(), basically before Magento 2.3.1 their is only this code.

 protected function _prepareLayout()
 {
 parent::_prepareLayout();
 $this->pageConfig->getTitle()->set(__('My Wish List'));
 return $this;
 }

After that this method turned into this:

 protected function _prepareLayout()
 {
 parent::_prepareLayout();
 $this->pageConfig->getTitle()->set(__('My Wish List'));
 // $this->getChildBlock('wishlist_item_pager')
 // ->setUseContainer(
 // true
 // )->setShowAmounts(
 // true
 // )->setFrameLength(
 // $this->_scopeConfig->getValue(
 // 'design/pagination/pagination_frame',
 // \Magento\Store\Model\ScopeInterface::SCOPE_STORE
 // )
 // )->setJump(
 // $this->_scopeConfig->getValue(
 // 'design/pagination/pagination_frame_skip',
 // \Magento\Store\Model\ScopeInterface::SCOPE_STORE
 // )
 // )->setLimit(
 // $this->getLimit()
 // )
 // ->setCollection($this->getWishlistItems());
 return $this;
 }

And the error above cause due to this addition code, So i commented addition code and my error disappeared, I know its not good to do changes in vendor, also I have a overridden file /app/design/frontend/Magestore/theme/Magento_Customer/layout/customer_account_index.xml, in this file their is code:

some code above...
 <block class="Magento\Wishlist\Block\Customer\Wishlist" name="customer.wishlist" template="customer_account_view.phtml" cacheable="false">
 <block class="Magento\Wishlist\Block\Rss\Link" name="wishlist.rss.link" template="rss/wishlist.phtml"/>
 <block class="Magento\Wishlist\Block\Customer\Wishlist\Items" name="customer.wishlist.items" as="items" template="item/list.phtml" cacheable="false">
 <block class="Magento\Wishlist\Block\Customer\Wishlist\Item\Column\Image" name="customer.wishlist.item.image" template="item/column/image.phtml" cacheable="false"/>
 <block class="Magento\Wishlist\Block\Customer\Wishlist\Item\Column\Info" name="customer.wishlist.item.name" template="item/column/name.phtml" cacheable="false"/>
 </block>
 </block>
some code below...

This code needs the $this->getChildBlock('wishlist_item_pager'), which is not in customer_account_index.xml, and if i try to add or remove (<referenceBlock name="wishlist_item_pager" remove="true"/>) this block = wishlist_item_pager,but by doing this my custom theme messed up, so i decided to go with old _prepareLayout() method.

Thank You.

answered Aug 29, 2019 at 11:25
0

I had do add the missing block

<block class="Magento\Theme\Block\Html\Pager" name="wishlist_item_pager"/>

to every block with the class Magento\Wishlist\Block\Customer\Wishlist.

answered Dec 16, 2020 at 13:45

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.