if (($subcatTotalItems > 0) || ('all' === $helper->getConfig('idxcat_show_subcats'))) {
                $subcatId = $subcat->getVar('categoryid');
                // if we retreived the last item object for this category
                if (isset($lastItemObj[$subcatId])) {
                    $subcat->setVar('last_itemid', $lastItemObj[$subcatId]->itemid());