<?php





$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$priceHelper = $objectManager->create('Magento\Framework\Pricing\Helper\Data');
$imageHelper  = $objectManager->get('\Magento\Catalog\Helper\Image');

$listBlock = $objectManager->get('\Magento\Catalog\Block\Product\ListProduct');


$categoryFactory = $objectManager->get('\Magento\Catalog\Model\CategoryFactory');
 
$categoryId = 25; // YOUR CATEGORY ID
$category = $categoryFactory->create()->load($categoryId);
 
$collection = $category->getProductCollection()
    ->addAttributeToSelect('*')->setPageSize(10);

$collection ->getSelect()->orderRand();
  
?>

<div class="container mnproduct">
    <div class="row">
        <div class="col-sm-12 blogmn">
            <h1>TOP SELLERS</h1>
        </div>
        
        <div class="col-sm-12">
            <?php foreach ($collection as $_product):?>
            <div class="proBox">
                <div class="picimg">
                <a href="<?php echo $_product->getProductUrl();?>">
                <img class="img-responsive" src="<?php echo $image_url = $imageHelper->init($_product, 'product_thumbnail_image')->setImageFile($_product->getFile())->resize(240, 300)->getUrl(); ?>" alt=""></a>
                </div>
                <div class="nmprice">
                    <h3><a href="<?php echo $_product->getProductUrl();?>"> <?php echo substr($_product->getName(), 0, 30) . '...';?></a></h3>
                <p><?php echo $priceHelper->currency($_product->getprice(), true, false);?> </p>
                    <!--<a href="#" class="bttn1"> Add to cart </a>-->
                    <?php $addToCartUrl =  $listBlock->getAddToCartUrl($_product);?>
                <form data-role="tocart-form" action="<?php echo $addToCartUrl; ?>" method="post"> 
                <?php echo $block->getBlockHtml('formkey')?>
                    <div class="btn">
                        <button type="submit" title="Add to Cart" class="action tocart primary">
                            <span>Add to Cart</span>
                        </button>
                    </div>   
                </form>
                </div>  
            </div>
            
           <?php endforeach; ?>
        </div>
    </div>
</div>

<?php 
echo $this->getLayout()
->createBlock('Magento\Cms\Block\Block')
->setBlockId('shop-essentials')
->toHtml();

echo $this->getLayout()
->createBlock('Magento\Cms\Block\Block')
->setBlockId('featured-brand')
->toHtml();


?>

<!--Grooming column Homepage start-->
<?php
$categoryIdmens = 32; // YOUR CATEGORY ID
$categorymens = $categoryFactory->create()->load($categoryIdmens);
 
$collectionMens = $categorymens->getProductCollection()
    ->addAttributeToSelect('*')->setPageSize(10);

$collectionMens ->getSelect()->orderRand();
?>
<div class="container mnproduct">
    <div class="row">
        <div class="col-sm-12 blogmn">
            <h1>Men's Grooming</h1>
        </div>
        
        <div class="col-sm-12">
            <?php foreach ($collectionMens as $_product):?>
            <div class="proBox">
                <div class="picimg">
                <a href="<?php echo $_product->getProductUrl();?>">
                <img class="img-responsive" src="<?php echo $image_url = $imageHelper->init($_product, 'product_thumbnail_image')->setImageFile($_product->getFile())->resize(240, 300)->getUrl(); ?>" alt=""></a>
                </div>
                <div class="nmprice">
                    <h3><a href="<?php echo $_product->getProductUrl();?>"> <?php echo substr($_product->getName(), 0, 30) . '...';?></a></h3>
                <p><?php echo $priceHelper->currency($_product->getprice(), true, false);?> </p>
                    <!--<a href="#" class="bttn1"> Add to cart </a>-->
                    <?php $addToCartUrl =  $listBlock->getAddToCartUrl($_product);?>
                <form data-role="tocart-form" action="<?php echo $addToCartUrl; ?>" method="post"> 
                <?php echo $block->getBlockHtml('formkey')?>
                    <div class="btn">
                        <button type="submit" title="Add to Cart" class="action tocart primary">
                            <span>Add to Cart</span>
                        </button>
                    </div>   
                </form>
                </div>  
            </div>
            
           <?php endforeach; ?>
        </div>
    </div>
</div>