class Index extends \Magento\Backend\App\Action{
/**
* @var PageFactory
*/
protected $resultPageFactory;
/**
* @param Context $context
* @param PageFactory $resultPageFactory
*/
public function __construct(
Context $context,
PageFactory $resultPageFactory
) {
parent::__construct($context);
$this->resultPageFactory = $resultPageFactory;
}
/**
* Index action
*
* @return \Magento\Backend\Model\View\Result\Page
*/
public function execute(){
/** @var \Magento\Backend\Model\View\Result\Page $resultPage */
$resultPage = $this->resultPageFactory->create();
$resultPage->setActiveMenu('Queueapp_Queueapp::queueapp_auth');
$resultPage->getConfig()->getTitle()->prepend(__('Queueapp'));
$this->setPageData();
return $resultPage;
}
protected function setPageData(){
// I want to access store data here e.g store name etc
// $store = Mage::app()->getRequest()->getParam('store');
$store = "me";
return $store;
}
}
-
What do you mean by store info? Can you add more info please.– Adarsh KhatriCommented Jan 21, 2016 at 22:18
Add a comment
|
1 Answer
Try it like this:
class Index extends \Magento\Backend\App\Action
{
/**
* @var PageFactory
*/
protected $resultPageFactory;
protected $storeFactory;
/**
* @param Context $context
* @param PageFactory $resultPageFactory
*/
public function __construct(
Context $context,
PageFactory $resultPageFactory,
\Magento\Store\Model\StoreFactory $storeFactory
) {
parent::__construct($context);
$this->resultPageFactory = $resultPageFactory;
$this->storeFactory = $storeFactory;
}
/**
* Index action
*
* @return \Magento\Backend\Model\View\Result\Page
*/
public function execute(){
/** @var \Magento\Backend\Model\View\Result\Page $resultPage */
$resultPage = $this->resultPageFactory->create();
$resultPage->setActiveMenu('Queueapp_Queueapp::queueapp_auth');
$resultPage->getConfig()->getTitle()->prepend(__('Queueapp'));
$this->setPageData();
return $resultPage;
}
protected function setPageData(){
$storeId = $this->getRequest()->getParam('store');
$store = $this->storeFactory->create()->load($storeId);
$name = $store->getName();
//do what ever you need with $store or $name
return $store;
}
}