How to get product by parent-category-id and sub-category-id?
Magento 2.0
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityHow to get product by parent-category-id and sub-category-id?
Magento 2.0
Use below code
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$categoryFectory = $objectManager->create('Magento\Catalog\Model\CategoryFactory');
$productCollection = $categoryFectory->load('category_id')->getProductCollection()->addAttributeToSelect('*');