Let’s initiate a discussion!!
I created Index.php controller for that at app/code/Vendor/Modulename/Controller/Index/ and add this below code :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
<?php namespace Vendor\Modulename\Controller\Index; class Index extends \Magento\Framework\App\Action\Action { /** * @var \Magento\Framework\View\Result\PageFactory */ protected $resultPageFactory; /** * @var \Magento\Framework\HTTP\Header */ protected $httpHeader; /** * @param \Magento\Framework\App\Action\Context $context * @param \Magento\Framework\HTTP\Header $httpHeader * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory */ public function __construct( \Magento\Framework\App\Action\Context $context, \Magento\Framework\HTTP\Header $httpHeader, \Magento\Framework\View\Result\PageFactory $resultPageFactory ) { $this->httpHeader = $httpHeader; $this->resultPageFactory = $resultPageFactory; parent::__construct($context); } /** * Detect Mobile view or Desktop View * * @return void */ public function execute() { $resultPage = $this->resultPageFactory->create(); $userAgent = $this->httpHeader->getHttpUserAgent(); $isMobile = \Zend_Http_UserAgent_Mobile::match($userAgent, $_SERVER); if ($isMobile) { $resultPage->getConfig()->getTitle()->prepend(__("Mobile View")); // Mobile view logic add here } else { $resultPage->getConfig()->getTitle()->prepend(__("Desktop View")); // Desktop view logic add here } return $resultPage; } } |
You can add this above code in your controller or any file. You need to inject \Magento\Framework\HTTP\Header class into your construct.
[crayon-641fb6e716da7409699796/] Using above fucntion Images can be imported directly from...
Override view block using di.xml and add the below code...
You can check a list of called layout XML for...
Follow the below steps to install and set up PWA...
If you want to remove all leading zero's from order,...
Let our Magento expert connect to discuss your requirement.
We offer Magento
certified developers.
Our Magento clientele
is 500+.
We sign NDA for the
security of your projects.
We’ve performed 100+
Magento migration projects.
Free quotation
on your project.
Three months warranty on
code developed by us.