I am trying to rewrite the protected function _prepareCollection method inside \Magento\Wishlist\Block\Customer\Wishlist however the wishlist page in my account now returns blank and it never makes it into the rewritten method.

Here is my di.xml

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">
    <preference for="Magento\Wishlist\Block\Customer\Wishlist" type="Namespace\Module\Block\Customer\Favorites" />

And here is my php file located at Namespace/Module/Block/Customer/Favorites


namespace Namespace\Module\Block\Customer;

class Favorites extends \Magento\Wishlist\Block\Customer\Wishlist
    protected function _prepareCollection($collection)

Am i missing something here ? I know that I can't use a plugin because they don't work with protected methods. Is that now the same with class rewrites as well ? Help!

2 Answers 2


Worked like a charm. Was trying to add a function for delete all wishlist by extending \Magento\Wishlist\Block\Customer\Wishlist but wasn't giving the desired output, but after adding the constructor it worked.


Try adding the following to your block class:

protected function _construct()
  • I had the very same problem and this method was only solution which worked. Thank you very much.
    – vladPavlov
    Commented Feb 20, 2017 at 15:01

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.