0

It's been commonly accepted you should never use \Magento\Framework\App\ObjectManager::getInstance() I can link sources explaining why if needed. Given this how would I go about getting the names of my categories if I should never use \Magento\Framework\App\ObjectManager::getInstance()? Thanks.

EDIT: I don't just want category names I'd like IDs and various other bits of information for each but names is a good start

3
  • 1
    check this answer , it follows the best practice
    – Piyush
    Feb 1, 2018 at 11:21
  • Thank you this was exactly what I was looking for @Piyush how do i close my own question?
    – John
    Feb 1, 2018 at 11:24
  • You can answer it and mark the answer accepted or delete it
    – Piyush
    Feb 1, 2018 at 11:25

1 Answer 1

0

Read the comments to the original question if you need a solution to my problem

    public function __construct(
    ...
    \Magento\Catalog\Model\ResourceModel\Category\CollectionFactory $collecionFactory
) {
    $this->_collectionFactory = $collecionFactory;
    parent::__construct(...);
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.