cancel
Showing results for 
Search instead for 
Did you mean: 

Display Subcategory image on category page in magento2

Display Subcategory image on category page in magento2

Hello everyone,

 

I was using this code for 2.0.2 version,but I can't seem to figure out the image path correctly. Here's the code I am using.

 

<?php $_categories = $block->getCurrentChildCategories();
$_count = is_array($_categories) ? count($_categories) : $_categories->count();
?>
<?php if ($_count): ?>
<div class="products wrapper grid products-grid">
<ol class="products list items product-items">
<?php foreach ($_categories as $_category): ?>
<?php if ($_category->getIsActive()):
?>
<li class="item product product-item category_listing">
<div data-container="product-grid" class="product-item-info">
<a tabindex="-1" class="product photo product-item-photo" href="<?php /* @escapeNotVerified */ echo $block->getCategoryUrl($_category) ?>">

<div style="width:240px;" class="product-image-container">
<div class="product-image-wrapper">
<img alt="<?php echo $block->escapeHtml($_category->getName()) ?>" src="<?php echo $_category->getImageUrl() ?>" class="product-image-photo">
</div>
</div>
</a>
<div class="category_details product details product-item-details">
<strong class="product name product-item-name">
<a href="<?php /* @escapeNotVerified */ echo $block->getCategoryUrl($_category) ?>" class="product-item-link">
<?php echo $block->escapeHtml($_category->getName()) ?>
</a>
</strong>
</div>
</div>
</li>
<?php endif; ?>
<?php endforeach ?>
</ol>
</div>
<?php endif; ?>

 

Thank you guys in advanced.

Tags (2)
1 REPLY

Re: Display Subcategory image on category page in magento2

Please anyone help to integrate this in Magento 2.0.2. I had found a way to integrate this in magento 1 by the code specified in the following page http://www.douglasradburn.co.uk/getting-category-thumbnail-images-with-magento/

 

Any help appreciated.