Commit c67be731 authored by Pradyuman Mishra's avatar Pradyuman Mishra

subcategory page

parent 35eac5b1
......@@ -21,6 +21,55 @@ $_productCollection = $block->getLoadedProductCollection();
$_helper = $this->helper('Magento\Catalog\Helper\Output');
$_config = $this->helper('Sm\Shop4u\Helper\Data');
?>
<?php
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$category = $objectManager->get('Magento\Framework\Registry')->registry('current_category');//get current category
$catId = $category->getId();
// $catId = 206;
$subCategory = $objectManager->create('Magento\Catalog\Model\Category')->load($catId);
$subCats = $subCategory->getChildrenCategories();
$_helper = $this->helper('Magento\Catalog\Helper\Output');
?>
<?php if($catId == 206): ?>
<div class="category-product products wrapper grid products-grid">
<ol class="products list items product-items row">
<?php
foreach ($subCats as $subcat) {
$_category = $objectManager->create('Magento\Catalog\Model\Category')->load($subcat->getId());
$subcaturl = $subcat->getUrl();
$_imgHtml = '';
if ($_imgUrl = $_category->getImageUrl()) {
$_imgHtml = '<img src="' . $_imgUrl . '" />';
$_imgHtml = $_helper->categoryAttribute($_category, $_imgHtml, 'image');
} ?>
<li class="item product product-item">
<div class="product-item-info" data-container="product-grid">
<div class="item-inner">
<div class="box-image">
<a href="<?php echo $subcaturl; ?>">
<span class="product-image-container">
<span class="product-image-wrapper">
<?php echo $_imgHtml;?>
</span>
</span>
</a>
</div>
<div class="product details product-item-details box-info">
<h2 class="product name product-item-name product-name">
<a class="product-item-link" href="<?php echo $subcaturl; ?>"><?php echo $subcat->getName(); ?> </a>
</h2>
</div>
</div>
</div>
</li>
<?php } ?>
</ol>
</div>
<?php else:?>
<?php if (!$_productCollection->count()): ?>
<div class="message info empty">
<div><?php /* @escapeNotVerified */
......@@ -364,3 +413,4 @@ $_config = $this->helper('Sm\Shop4u\Helper\Data');
</script>
<?php endif; ?>
<?php endif; ?>
<?php endif; ?>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment