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
-
are you using any custom method where you call setUseContainer() ?Asad Ullah– Asad Ullah2019年08月28日 12:57:43 +00:00Commented Aug 28, 2019 at 12:57
4 Answers 4
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"/>
.
.
.
-
awesome working for me...MageCurious– MageCurious2019年10月04日 09:25:47 +00:00Commented Oct 4, 2019 at 9:25
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.
-
Thanks mate, but i have another file
customer_account_index.xml, which cause this error andwishlist_index_index.xmlcausing theme issue... I posted another answer.Partab Saifuddin Zakir– Partab Saifuddin Zakir2019年08月29日 12:58:46 +00:00Commented Aug 29, 2019 at 12:58
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.
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.
Explore related questions
See similar questions with these tags.