How to get names, IDs and details of my categories without falling in to bad practice?
-
29-12-2020 - |
Question
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
La solution
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(...);
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à magento.stackexchange