如何在产品详细信息页面中获取类别集合。我尝试使用下面的代码,但没有得到集合。怎么得到的?
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$category = $objectManager->get('Magento\Framework\Registry')
->registry('current_category');
$categoryProducts = $category->getCategoryProducts($categoryId);
在产品详细信息页面上,您只需在产品的Object上调用getCategoryCollection函数即可获取Category Collection,如下所示:
$_product = $block->getProduct();
$categoryCollection = $_product->getCategoryCollection();
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句