2

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

  • are you using any custom method where you call setUseContainer() ? – Asad Ullah Aug 28 at 12:57
2

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

  • 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. – Partab Saifuddin Zakir Aug 29 at 12:58
2

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"/>
.
.
.
0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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