0
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;
     }
}
1
  • What do you mean by store info? Can you add more info please. Commented Jan 21, 2016 at 22:18

1 Answer 1

0

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;
     }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.