Hi I have problem in Define model constructor, This is my code:
<?php namespace Retailers\Company\Model\Category; use \Magento\Framework\Option\ArrayInterface; class CategoryList implements ArrayInterface { protected $_categoryCollectionFactory; public function __construct( \Magento\Catalog\Model\ResourceModel\Category\CollectionFactory $collectionFactory, array $data = [] ) { $this->_categoryCollectionFactory = $collectionFactory; } public function toOptionArray($addEmpty = true) { /** @var \Magento\Catalog\Model\ResourceModel\Category\Collection $collection */ $collection = $this->_categoryCollectionFactory->create(); $collection->addAttributeToSelect('name');//->addRootLevelFilter()->load(); $options = []; if ($addEmpty) { $options[] = ['label' => __('-- Please Select a Category --'), 'value' => '']; } foreach ($collection as $category) { $options[] = ['label' => $category->getName(), 'value' => $category->getId()]; } return $options; } }