Pergunta

I have the parent category "XXX" and having around 115 subcategories under the same.

I am trying to sort the subcategories listed under of specific parent category at the backend... enter image description here

Foi útil?

Solução

Use like below.

protected $_categoryCollection;

public function __construct(
 \Magento\Backend\Block\Template\Context $context,
 \Magento\Catalog\Model\ResourceModel\Category\CollectionFactory $categoryCollection,
  array $data = []
 )
{
   $this->_categoryCollection = $categoryCollection;
   parent::__construct($context, $data);
}
public function getCategoryCollection()
 {
   $categoryId = "your parent categoryId";
    $collection = $this->_categoryCollection->create()->load($categoryId)
    ->addAttributeToSelect('*')
    ->addAttributeToSort('position', 'asc');
    return $collection;
}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a magento.stackexchange
scroll top