I was wondering if there was a better way to use the resources than object manager, here is how i'm currently using the category factory's. I am very new to Magento.
<?php
namespace XX\TierPriceSummary\Block\Adminhtml\Index;
class Index extends \Magento\Backend\Block\Widget\Container
{
protected $_customerGroupsCollection;
protected $_productRepository;
protected $_resource;
private $storeID = 1;
public function __construct(
\Magento\Backend\Block\Widget\Context $context,
\Magento\Customer\Model\ResourceModel\Group\Collection $customerGroupsCollection,
\Magento\Catalog\Model\ProductRepository $productRepository,
\Magento\Framework\App\ResourceConnection $resource,
array $data = []
) {
$this->_customerGroupsCollection = $customerGroupsCollection;
$this->_productRepository = $productRepository;
$this->_resource = $resource;
parent::__construct(
$context,
$data
);
}
private function getProductTierPrice($SubCategoryID,$pID,$groupID){
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$categoryFactory = $objectManager->get('\Magento\Catalog\Model\CategoryFactory');
$categoryHelper = $objectManager->get('\Magento\Catalog\Helper\Category');
$categoryRepository = $objectManager->get('\Magento\Catalog\Model\CategoryRepository');
//do something
}
}