I have this category structure below:

enter image description here

When I access Men page all products of child categories are there, but they are showing in a random mode, i believe. I want to show the products in the main category (Men) sorted by child categories order.

Product Collection function:

public function getProductCollection()
        $current_category = $this->_registry->registry('current_category');//get current category
        $collection = $this->_productCollectionFactory->create();
        $collection->addAttributeToFilter('visibility', \Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH);
        return $collection;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.