0
<?php
namespace Module_dir\Block\Customer;
use Psr\Log\LoggerInterface;

class Addproduct extends \Magento\Framework\View\Element\Template
{
    protected $adminCategoryTree;
    protected $logger;
    /**
     * @param \Magento\Framework\View\Element\Template\Context $context
     * @param \Magento\Catalog\Helper\Category $categoryHelper
     * @param array $data
     */
    public function __construct(
        \Magento\Framework\View\Element\Template\Context $context,
        LoggerInterface $logger,
        \Magento\Catalog\Block\Adminhtml\Category\Tree $adminCategoryTree,
        array $data =[]

    )
    {
        parent::__construct($context,$data);
        $this->adminCategoryTree = $adminCategoryTree;
        $this->logger=$logger;
    }
public function getTree()
{
    return $this->adminCategoryTree->getTree();
}
}

getTree() method return the array in tree Now How can show it in .phtml in dropdown list. it should be differentiate parent and child category.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.