Hello,
I want to add multiple categories ids but its not working (With 1 category its working) in this widget
https://i.stack.imgur.com/dePEX.png
And also I can't view the information anymore in the front end because I have this error: We're sorry, an error has occurred while generating this content.
These are my log files...
exception.log & debug.log
main.CRITICAL: Notice: Undefined offset: 1 in app/design/frontend/Mimosa/mimosa5/Plazathemes_Categorytab/templates/categorytab/grid.phtml on line 160 {"exception":"[object] (Exception(code: 0): Notice: Undefined offset: 1 in app/design/frontend/Mimosa/mimosa5/Plazathemes_Categorytab/templates/categorytab/grid.phtml on line 160 at vendor/magento/framework/App/ErrorHandler.php:61)"} []
And this is the code of the file grid.phtml:
<?php $catIds = $_item->getCategoryIds(); $_objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $object_manager = $_objectManager->create('Magento\Catalog\Model\Category')->load($catIds[1]); ?> <a href="<?php echo $object_manager->getUrl(); ?>" class="cate"><?php echo $object_manager->getName(); ?></a> <?php if ($templateType): ?> <?php echo $block->getReviewsSummaryHtml($_item, $templateType,true); ?> <?php endif; ?> <strong class="product-item-name"> <a title="<?php echo $block->escapeHtml($_item->getName()) ?>" href="<?php echo $block->getProductUrl($_item) ?>" class="product-item-link"> <?php echo $block->escapeHtml($_item->getName()) ?> </a> </strong> <div class="item-price"> <?php echo $block->getProductPrice($_item); ?> </div>
You can explode all the Ids with "," and than get one by one value from it using foreach loop you can load particular category from object manager.