I try to get years of some awards product, but want avoid duplicate years, so I using group by but it not show nothing, when I remove it, code working but not show right what I want, below is snippet code:
* <div class="cms-sticky-content">
* <ul>
* <?php
* //$collection = $collection->getSelect()->group('aw_year');
* //print_r($collection->__toString()); die;
* $collection = $this->getSelect()->group('aw_year');
*
* //print_r($new_collection->__toString()); die;
* //print_r($collection->count()); die;
* foreach ($collection as $year) {
*
* echo '<li><a href="#' . $year->getData("aw_year"). '"><span><span>' .$year->getData('aw_year'). '</span></span></a></li>';
* }
*
*
* ?>
* </ul>
* </div>
This is error:
So how I can do it: