<?php
/***************************************************************************
 Extension Name  : Magento2 Shop By Brand Extension
 Extension URL   : http://www.magebees.com/magento2-shop-by-brand-extension.html
 Copyright    : Copyright (c) 2016 MageBees, http://www.magebees.com
 Support Email   : support@magebees.com 
 ***************************************************************************/
?>
<?php
namespace Nexus\Catalog\Block;
use Magento\Store\Model\ScopeInterface;
class BrandProductView extends \Magento\Framework\View\Element\Template
{
    protected $configValues = array();
    protected $responsivebannerslider;
    protected $brands;
    protected $coreRegistry;
	protected $_cmsPage;
	protected $_storeManager;
	protected $_product;

	public function __construct(
        \Magento\Framework\View\Element\Template\Context $context,
		\Magento\Framework\App\Request\Http $request,
		\Magento\Framework\Registry $coreRegistry,
		\Magento\Catalog\Model\Product $product,
		\Magento\Catalog\Model\CategoryFactory $categoryFactory,
		\Magento\Store\Model\StoreManagerInterface $storeManagerInterface
	  
    ) {
        parent::__construct($context);
		$this->_request = $request;
		$this->_coreRegistry = $coreRegistry;
		$this->_product = $product;
		$this->_categoty = $categoryFactory;
		$this->_storeManager = $storeManagerInterface;

	}
	
	public function getCurrentproduct(){
		$productid = $this->_coreRegistry->registry('current_product')->getId();
		return $productid;
	}
	
	public function getProducts($id){
		return $this->_product->load($id);
	}

	public function getCategory($brandname){
			
			if($this->_storeManager->getStore()->getId() == 1 ){
					$allbrandCollection = $this->_categoty->create()->getCollection()->addAttributeToSelect('*')->addAttributeToFilter('name', array('like' => $brandname."%"))->addAttributeToFilter('is_active','1')->addAttributeToFilter('parent_id', array('eq' => 33))->addAttributeToSort('name', 'asc')->setStoreId($this->_storeManager->getStore()->getId())->getFirstItem();
			}elseif($this->_storeManager->getStore()->getId()== 3 ){
					$allbrandCollection = $this->_categoty->create()->getCollection()->addAttributeToSelect('*')->addAttributeToFilter('name', array('like' => $brandname."%"))->addAttributeToFilter('is_active','1')->addAttributeToFilter('parent_id', array('eq' => 1277))->addAttributeToSort('name', 'asc')->setStoreId($this->_storeManager->getStore()->getId())->getFirstItem();

			}

		return 	$allbrandCollection;

	}
	
}