Magento2 获取子目录

< referenceContainer name="columns.top" >
< block class="Magento\Catalog\Block\Category\View" name="subcategory" template="Magento_Catalog::category/subceategory.phtml" before="-" after="category.view.container" />
< /referenceContainer >

================================

< ?php $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $category = $objectManager->get('Magento\Framework\Registry')->registry('current_category');
$subcats = $category->getChildrenCategories();
? >
< div class="new-ceategory">

    < ?php foreach ($subcats as $subcat) { if ($subcat->getIsActive()) {
    $subcat_url = $subcat->getUrl();
    $subcategory = $objectManager->create('Magento\Catalog\Model\Category')->load($subcat->getId());
    $subcat_img = $subcategory->getImageUrl();
    $placeholder_img = "/media/preview.jpg";
    ? >


  • < img src="" height="200" width="200" / >< /a >

    getName(); ?>

    < /li >
    < ?php }}? >
    < /ul >
    < /div >

    sub-category

发表评论
Magento2 技术支持 上门服务

工作时间
周一至周六
9:00-18:00
相关咨询电话
15360669780
侨海科技