I am working on Magento 2.0.4 . I need to get collection of my custom table. For this I created the function getAreaCollection()
in my block file but I got following error when I add constructor in block file.
Object DOMDocument should be created.
Here is my block file (\app\code\Techno\Area\Block\Area\index.php):-
namespace Techno\Area\Block\Area;
use Techno\Area\Block\BaseBlock;
use Techno\Area\Model\Area as AreaModel;
use Techno\Area\Model\Status;
class Index extends BaseBlock {
protected $_areaFactory;
protected $_area;
protected $_areaCollectionFactory;
protected $_areaHelper;
public function __construct(
Magento\Framework\View\Element\Template\Context $context
Techno\Area\Model\ResourceModel\Area\CollectionFactory $areaCollectionFactory,
Techno\Area\Model\AreaFactory $areaFactory,
AreaModel $area,
Techno\Area\Helper\Data $areaHelper
) {
parent::__construct($context);
$this->_areaFactory = $areaFactory;
$this->_area = $area;
$this->_areaCollectionFactory = $areaCollectionFactory;
$this->_areaHelper = $areaHelper;
}
public function getAreaCollection() {
$areaCollection = $this->_areaCollectionFactory->create()
->addFieldToFilter('status', Status::STATUS_ENABLED)
->setOrder('area_name', 'ASC');
return $areaCollection;
}
}
Can anyone guide me to make this working ?