protected function _getChilds() { if ($this->_childs === null) { $this->_childs = $this->_categoryCollectionFactory->create()->getGroupedChilds(); } return $this->_childs; }
/** * Options getter * * @return array */ public function toOptionArray() { if ($this->options === null) { $this->options = [['label' => __('Please select'), 'value' => 0]]; $collection = $this->categoryCollectionFactory->create(); $collection->setOrder('position')->getTreeOrderedArray(); foreach ($collection as $item) { $this->options[] = ['label' => $this->_getSpaces($item->getLevel()) . ' ' . $item->getTitle() . ($item->getIsActive() ? '' : ' (' . __('Disabled') . ')'), 'value' => $item->getId()]; } } return $this->options; }
/** * Retrieve post parent categories * @return \Magefan\Blog\Model\ResourceModel\Category\Collection */ public function getParentCategories() { if (is_null($this->_parentCategories)) { $this->_parentCategories = $this->_categoryCollectionFactory->create()->addFieldToFilter('category_id', array('in' => $this->getCategories()))->addStoreFilter($this->getStoreId())->addActiveFilter(); } return $this->_parentCategories; }
/** * @param string $name * @param string $primaryFieldName * @param string $requestFieldName * @param CollectionFactory $categoryCollectionFactory * @param DataPersistorInterface $dataPersistor * @param array $meta * @param array $data */ public function __construct($name, $primaryFieldName, $requestFieldName, CollectionFactory $categoryCollectionFactory, DataPersistorInterface $dataPersistor, array $meta = [], array $data = []) { $this->collection = $categoryCollectionFactory->create(); $this->dataPersistor = $dataPersistor; parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data); $this->meta = $this->prepareMeta($this->meta); }