Without actually running your code, the reasons for this can be difficult to find.
This is not a solution for the actual issue, but a description on how to debug this type of issue. I hope it helps you towards solving the issue.
I hope it also shows to others how important it is to use breakpoints with a debugger to solve a lot of magento 'why the f**ck is this not working' issues.
Are you using a debugger? This type of issue is easy to solve if you use a debugger, and step through the code, and check all the variables, values etc. Without this you are really just taking pot shots in the dark.
btw, I use netbeans with xdebug. (just in case you need a solution for that ;) )
Now, that all said, this is how I would start with the debug of this.
In list.phtml the toolbar is fetched via the code <?php echo $this->getToolbarHtml() ?>
, thus I would start by whacking a breakpoint on that line, and then step into the routine to find why...
ok, so stepping in, I find this code:
/**
* Retrieve list toolbar HTML
*
* @return string
*/
public function getToolbarHtml()
{
return $this->getChildHtml('toolbar');
}
thus, is the child block attached?
yes it is, so that is not the issue.
Lets see what template is used for this block.
Using the debugger, I can expand the toolbar child block, and view all its properties/values etc. The template is:
So, lets go do a break point in that file, and see code flow from there...
The first line of code in that template is <?php if($this->getCollection()->getSize()): ?>
Using the debugger, I can step over this line, and confirm it evaluates to true, if not ? why not....
And here my example ends, as the line in the tolbar could be your issue....
I hope this example helps, and show you how important it is to use a real debugger when coding with magento (or any application for that matter) :)
Using breakpoints, and stepping through the code, and actually have the ability to view all the classes/objects/values etc during a run, makes it pretty easy to solve this type of issue.
Have fun :)
Best Answer
To do so you need to use the
Magento\Wishlist\Controller\WishlistProviderInterface
interface.Inject this class in your constructor:
Then you can call the following to get the current logged in user wishlist: